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 Platform Community / Forums / Power Automate / Office Scripts: Unable...
Power Automate
Answered

Office Scripts: Unable to copy paste filtered rows of table to new worksheet

(0) ShareShare
ReportReport
Posted on by 94

I am trying to apply filter to a Excel table using office scripts and copy the data to a new worksheet. I am using getVisibleView() but it pastes all data to new worksheet, and not just the filtered rows.

 

 

 

 

 

 table1 = workbook.getTable("Table1");

 // Apply checked items filter on table table1 column Logged in Last 120 Days?
 table1.getColumnByName("Logged in Last 120 Days?").getFilter().applyValuesFilter(["YES"]);

 // Add a new worksheet
 let QuarterMapping = workbook.addWorksheet(QuarterMappingSheetname);

 const source = table1.getRange().getVisibleView().getRange();

 // Copy the data into the other sheet.

 const otherRangeCorner = QuarterMapping.getRange("A1");
 otherRangeCorner.copyFrom(source, ExcelScript.RangeCopyType.all);
 

 

 

 

 

 

Categories:
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Neha2904 ,

     

    I've made a test but it worked well on my side:

    vbofengmsft_0-1658802617436.png

    function main(workbook: ExcelScript.Workbook) {
     workbook.getTable("Table1").getColumnByName("Logged in Last 120 Days?").getFilter().applyValuesFilter(["YES"]);
    
     // Add a new worksheet
     let QuarterMapping = workbook.addWorksheet("QuarterMappingSheetname");
    
     const source = workbook.getTable("Table1").getRange().getVisibleView().getRange();
    
     // Copy the data into the other sheet.
    
     const otherRangeCorner = QuarterMapping.getRange("A1");
     otherRangeCorner.copyFrom(source, ExcelScript.RangeCopyType.all);
    }

    vbofengmsft_1-1658802655556.png

     

    Best Regards,

    Bof

     

     

     

  • geddb Profile Picture
    109 on at

    Hi @v-bofeng-msft,

     

    I'm having the same issue. I have replicated your test exactly and I am not getting the filtered data on the new sheet 'QuarterMappingSheetname'. Am I doing something wrong?

     

    geddb_1-1708300102310.png

     

     



    Many thanks,

     

    Gedd.

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 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard