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 Platform Community / Forums / Power Automate / Scheduled Flow for del...
Power Automate
Unanswered

Scheduled Flow for deleting contents in table

(0) ShareShare
ReportReport
Posted on by 6

Hello Community,

 

I want to learn how to delete the contents of a given table in excel in OneDrive using Power Automate Scheduled Flow. It must be triggered at a designated day and time. Please help!

 

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    on at

    Hi @dazler5540 ,

     

    I made a sample for you.

    vxiaochenmsft_0-1676864047069.png

    vxiaochenmsft_1-1676864054954.png

     

    Please make sure that Excel table has a primary column (In my screenshots, it's Col1.) because Power Automate doesn’t allow you to remove empty rows from an Excel file. The ‘Delete a row’ action needs an identifier of the specific row, and it can’t be empty. 

     

    Best Regards,

    Wearsky

  • Suggested answer
    CU17101209-0 Profile Picture
    2 on at
    Just recently ran into this problem myself, and I don't like using the list all rows, delete row combination since it deletes rows one at a time and that can be super slow for tables of more than 100 rows.
     
     
    The approach I used was using an Office Script. The script body is:
     
    function main(workbook: ExcelScript.Workbook, tableName: string): string{
      const tbl = workbook.getTable(tableName);
    
      if (!tbl){
        let tbls = workbook.getTables();
        let names = tbls.map(tbl => tbl.getName()).join(', ');
        return `[ERROR] No table found ${tableName}. Found tables:\n[${names}]`;
      }
    
      try {
        // This could be made more complicated for really large tables > 1 million rows to avoid timeout errors
        tbl.getRangeBetweenHeaderAndTotal().delete(ExcelScript.DeleteShiftDirection.up);
        return "Success"
      }
      catch(e){
        return `[ERROR] Unable to delete table range. Received error:\n${e}`;
      }
    }
     
    Then you simply make a power automate flow, using the "Run Script" action
    In the above example I'm using a manual trigger, but that could super easily be changed to a scheduled trigger.

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