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

Announcements

News and Announcements icon
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:
  • 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 315 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 267

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard