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 / 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!

 

  • Verified answer
    CU16071609-1 Profile Picture
    6,255 Moderator 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

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

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard