Button Controlled Macro to Delete Sheet If It Exists

  • Hello,


    I've got a workbook that users use a form control button to create additional sheets. I would also like to create a button to delete sheets if needed. The code below works to delete the sheet, but if the user tries to delete a sheet that doesn't exist it generates an error. Any way to modify the code so if a user enters the name of sheet that doesn't exist the macro won't generate an error?



    Thank you!!

  • Try adding the lines I have highlighted.

  • Sbox134 you can use evaluate formula.to check exist sheet

  • Hi Alan,


    Thank you for the help and prompt reply. I've tried the code you suggested, but if I enter a sheet name that doesn't exist the macro still deletes the active sheet instead of doing nothing. Any other ideas?


    Below is the code directly out of the module:


  • Thank you both AlanSidman and graha_karya for the replies. I wasn't able to get the code graha_karya provided to work, but after a few modifications was able to make it fit my needs. The code that worked for me, in case anyone has a similar issue, is:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!