web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

OFFICE SCRIPT HELP

(0) ShareShare
ReportReport
Posted on by 32

I have a automate script that can do the filter data based on specific column, and I'm looking for to copy that data and paste it to complete new worksheet and delete the filter worksheet. 

 

Most of the ways I've been trying always come back with the result as it will copy everything from the original worksheet to new worksheet. How can I just copy a data filter ONLY to new worksheet like we manually copy and paste to worksheet? Please helppp!!.

 

I possibly would be able to do this with Macro, but how can I make it run automatically after my power automate flow finish with office script in XLSX file format? 

 

Categories:
I have the same question (0)
  • AlexEncodian Profile Picture
    4,409 Moderator on at

    @biboy852 

     

    How about getting all the data into PowerAutomate and using Filter Array action to filter you data before creating a worksheet with that filtered data?

     

     

  • biboy852 Profile Picture
    32 on at

    Hi the flow would be too complicated so I rather try office script. Since I already got the result, I just need to copy filter data and paste to new worksheet. 

    Thank you.

  • MichelleRanMSFT Profile Picture
    Microsoft Employee on at

    Hi @biboy852., thanks for your question! To confirm, you have a range of data with a filter applied to it, and you'd like to copy only the filtered (visible) data to another worksheet? In that case, you can use the following code:

    function main(workbook: ExcelScript.Workbook) {
     let table = workbook.getTable('your table name');
     let visibleRange = table.getRange().getVisibleView().getRange()
     workbook.getWorksheet('destination sheet').getRange('A1').copyFrom(visibleRange);
    }

    You can replace "A1" with the address of the top-left cell of the range where you'd like to paste your data. If your data isn't in a table, this code may work instead:

    function main(workbook: ExcelScript.Workbook) {
     let visibleRange = workbook.getWorksheet('source sheet').getRange('the complete range of data').getVisibleView().getRange();
     workbook.getWorksheet('destination sheet').getRange('A1').copyFrom(visibleRange);
    }

     Hopefully that helps! Let me know if you have any further questions.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard