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

Community site session details

Session Id :
Power Automate - Building Flows
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);
 

 

 

 

 

 

I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: Office Scripts: Unable to copy paste filtered rows of table to new worksheet

    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
    Re: Office Scripts: Unable to copy paste filtered rows of table to new worksheet

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 788 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 452 Moderator

#3
developerAJ Profile Picture

developerAJ 302

Last 30 days Overall leaderboard