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 workshee...
Power Automate
Answered

how to delete worksheet without name '%Success%'

(1) ShareShare
ReportReport
Posted on by

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

How to do that? Thank you.

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

    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

     

  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,250 Super User 2025 Season 2 on at

    @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 🚀

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