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

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:
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

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
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard