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 / Delete Row From Excel ...
Power Automate
Answered

Delete Row From Excel Worksheet

(0) ShareShare
ReportReport
Posted on by 19

Good Morning,

 

I was having trouble when running my code regarding the Delete Row from Excel Sheet Function. I have certain keywords in my data, and if the row contains this key word I need to delete it. I have used the Find and replace cells in Excel Worksheet Function to find all of my keywords and change them to the word delete. I then find all cells with the text delete and store them on a separate table. However, I am unsure on how to actually use the Delete Row from Excel Worksheet function to delete all of my desired Rows. Any help is appreciated.

I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @KaiHalpin ,

     

    Please find the solution.

    Note: For Data I have created a DataTable.

    VishnuReddy1997_0-1719247272194.png

     

    Code:

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice\\Excel\\Input\\0048600218_2024-APR-U002M204.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Variables.CreateNewDatatable InputTable: { ^['Input'], [$'''D55'''], [$'''U432'''], [$'''U433'''], [$'''U435'''], [$'''U435'''] } DataTable=> DataTable
    LOOP FOREACH CurrentItem IN DataTable
     Excel.FindAndReplace.FindSingle Instance: ExcelInstance TextToFind: CurrentItem MatchCase: False MatchEntireCellContents: False SearchBy: Excel.SearchOrder.Rows FoundColumnIndex=> FoundColumnIndex FoundRowIndex=> FoundRowIndex
     Display.ShowMessageDialog.ShowMessage Message: FoundRowIndex Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
     IF FoundRowIndex <> 0 THEN
     Excel.DeleteRow Instance: ExcelInstance Index: FoundRowIndex
     END
    END

     

    (Note:- if you got your solution you can mark as solution and gives kudos)


    Thanks & Regards

    Vishnu Reddy

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KaiHalpin 

     

    Please follow the below approach:

    Deenuji_0-1719251597510.png

     

    Code:

     

    Variables.CreateNewDatatable InputTable: { ^['Column1', 'Column2'], [$'''Metered Raye''', $''':1000'''], [$'''Tubing Pressure''', $''':495'''], [$'''Mechanical Loss''', $''''''], [$'''Interval Type: Interval %% Loss Remarks''', $''''''], [$'''______________________________________''', $''''''], [$'''1420 - 1503 PERI 1450 - 1490 77%%''', $''''''], [$'''1580 - 1561 PERI 15200 - 1561 23%%''', $''''''], [$'''Lower B''', $''''''], [$'''______________________________________''', $''''''], [$'''Metered Rate''', $''':650 B/D'''], [$'''Tubbing Pressure''', $''':570 PSI'''] } DataTable=> DataTable
    Variables.FindOrReplaceInDataTable.FindItemInDataTableByColumnIndex DataTable: DataTable AllMatches: True ValueToFind: $'''__''' MatchCase: False MatchEntireCellContents: False ColumnNameOrIndex: 0 DataTableMatches=> DataTableMatches
    SET StartRow TO DataTableMatches[0][0]
    Text.ToNumber Text: StartRow Number=> StartRowAsNum
    SET StartRowAsNum TO StartRowAsNum + 1
    LOOP LoopIndex FROM 1 TO StartRowAsNum STEP 1
     Variables.DeleteRowFromDataTable DataTable: DataTable RowIndex: 0
    END
    Variables.FindOrReplaceInDataTable.FindItemInDataTableByColumnIndex DataTable: DataTable AllMatches: True ValueToFind: $'''Lower''' MatchCase: False MatchEntireCellContents: False ColumnNameOrIndex: 0 DataTableMatches=> DataTableMatches
    SET EndRow TO DataTableMatches[0][0]
    Text.ToNumber Text: EndRow Number=> EndRowAsNum
    SET EndRowAsNum TO EndRowAsNum
    LOOP LoopIndex FROM EndRowAsNum TO DataTable.RowsCount STEP 1
     Variables.DeleteRowFromDataTable DataTable: DataTable RowIndex: EndRowAsNum
    END

     

     

     

    How to copy/paste the above code in your power automate desktop?

    Deenuji_1-1719251687591.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 🚀

  • KaiHalpin Profile Picture
    19 on at

    Thanks for the response, but it didn't apply to my situation. I have a table like this (see attached image) where I have the rows that I need to delete stored in a table. All of the values in the column that is labelled Row Index are the numbers of the rows that I need to delete on my Excel Sheet. I need a way to delete all of these values that are on the spreadsheet itself. 

     

    Edit: Resolved

    RowsToDelete.PNG
  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KaiHalpin 

     

    You can follow the below approach:

    Deenuji_0-1719286746593.png

     

     


    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 🚀

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @KaiHalpin ,

     

    Did you tried my solution,just try and let me know.

     

    Regards,

    Vishnu Reddy

  • NathanAlvares24 Profile Picture
    1,714 Moderator on at

    Hi @KaiHalpin !

     


    @KaiHalpin wrote:

    Thanks for the response, but it didn't apply to my situation. I have a table like this (see attached image) where I have the rows that I need to delete stored in a table. All of the values in the column that is labelled Row Index are the numbers of the rows that I need to delete on my Excel Sheet. I need a way to delete all of these values that are on the spreadsheet itself.


    You could just use a for each loop and loop through this datatable and grab the 2nd column (index will be 1) and use the action "Delete row from Excel worksheet" to achieve your requirements.

    NathanAlvares24_0-1719290833908.png

     

    I hope this helps.

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 252 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard