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 / How to Delete the last...
Power Automate
Answered

How to Delete the last three rows in Power Automate Deskop

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

Hello,

Can someone please help me on how to delete the last three rows in PAD?  I've tried everything (-1, -2, and -3) nothing seems to work.

I have other excel file that the delete work, but it does not work on this file.  I am wondering why? I am guessing it's because the grand total is not on row 90?  This is how I got the file from the customer, but I need PAD to treat it and delete the last 3 rows.

TTC_0-1714051538700.pngTTC_1-1714051621386.png

Thank you an advance!

 

I have the same question (0)
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @TTC 

     

    Please follow the below approach.

    1. Launching Excel and opening a specific file

    2. Reading data from Excel

    3. Determining the number of rows in Excel data and add one into it for header

    4. Looping to delete rows for three time and delete the last rows each time

    Deenuji_1-1714052977655.png

     

    Code:

     

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Boot\\Invoice.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.ReadFromExcel.ReadAllCells Instance: ExcelInstance ReadAsText: False FirstLineIsHeader: True RangeValue=> ExcelData
    SET ExcelRowscount TO ExcelData.RowsCount + 1
    LOOP LoopIndex FROM 1 TO 3 STEP 1
     Excel.DeleteRow Instance: ExcelInstance Index: ExcelRowscount
     SET ExcelRowscount TO ExcelRowscount - 1
    END

     

     

    How to copy and paste the above code into your desktop flows?

    Deenuji_2-1714053048093.gif

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Thank you so much!

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard