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

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

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 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

  • Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 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,656 Super User 2025 Season 2 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

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

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard