Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

how to delete worksheet without name '%Success%'

Like (1) ShareShare
ReportReport
Posted on 9 Jul 2024 08:31:07 by

I would like to delete worksheet in an Excel, which name should not be include text 'Success'.

How to do that? Thank you.

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,118 Super User 2025 Season 1 on 09 Jul 2024 at 09:06:26
    Re: how to delete worksheet without name '%Success%'

    @Tracy1 

     

    Please follow the below approach:

    Deenuji_0-1720515949056.png

     

    Code:

    Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\Downloads\\EmpDetails_Sheet1.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
    Excel.GetAllWorksheets Instance: ExcelInstance Worksheets=> SheetNames
    Display.ShowMessageDialog.ShowMessage Title: $'''Info''' Message: SheetNames Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    LOOP FOREACH CurrentItem IN SheetNames
     IF NotContains(CurrentItem, $'''Success''', True) THEN
     Excel.DeleteWorksheet.DeleteWorksheetByName Instance: ExcelInstance Name: CurrentItem
     END
    END
    Excel.CloseExcel.CloseAndSave Instance: ExcelInstance

     

     


    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 🚀

  • Verified answer
    VishnuReddy1997 Profile Picture
    2,324 Super User 2025 Season 1 on 09 Jul 2024 at 08:49:51
    Re: how to delete worksheet without name '%Success%'

    Hi @Tracy1 ,

     

    Please find the solution.

     

    VishnuReddy1997_0-1720516906226.png

     

    Code:

     

     

    FUNCTION 'User Input' GLOBAL
     Excel.LaunchExcel.LaunchAndOpenUnderExistingProcess Path: $'''C:\\Users\\vr79540\\Desktop\\Power Automate Desktop\\Practice\\Excel\\Positive.xlsx''' Visible: True ReadOnly: False Instance=> ExcelInstance
     Excel.GetAllWorksheets Instance: ExcelInstance Worksheets=> SheetNames
     LOOP FOREACH CurrentItem IN SheetNames
     IF NotContains(CurrentItem, $'''Success''', True) THEN
     Excel.DeleteWorksheet.DeleteWorksheetByName Instance: ExcelInstance Name: CurrentItem
     END
     END
     Excel.CloseExcel.CloseAndSave Instance: ExcelInstance
    END FUNCTION

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


    Thanks & Regards

    Vishnu Reddy

     

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Automate - Power Automate Desktop

#1
eetuRobo Profile Picture

eetuRobo 147 Super User 2025 Season 1

#2
Riyaz_riz11 Profile Picture

Riyaz_riz11 56 Super User 2025 Season 1

#3
Nived_Nambiar Profile Picture

Nived_Nambiar 30 Super User 2025 Season 1

Overall leaderboard
Loading started