Locating if a Sheet is present in a workbook
Two Part Question:
I am looking for code that will locate if a sheet by a specific name is in the workbook, and then delete it if it is. What is the easiest way to do this? (I am not sure if an "IF" statement is the best way to go or not). Secondly, is there a way to keep the warning pop-up from occurring when trying to delete said sheet? Thanks! |
Locating if a Sheet is present in a workbook
for each ws in worksheets
application.displayalerts =false if ws.name="Bad Name" then ws.delete application.displayalerts=true next ws -- Don Guillett Microsoft MVP Excel SalesAid Software "Shane" wrote in message ... Two Part Question: I am looking for code that will locate if a sheet by a specific name is in the workbook, and then delete it if it is. What is the easiest way to do this? (I am not sure if an "IF" statement is the best way to go or not). Secondly, is there a way to keep the warning pop-up from occurring when trying to delete said sheet? Thanks! |
Locating if a Sheet is present in a workbook
on error resume next
application.displayalerts = false sheets("Sheet1").Delete application.displayalerts = true on error goto 0 -- HTH... Jim Thomlinson "Shane" wrote: Two Part Question: I am looking for code that will locate if a sheet by a specific name is in the workbook, and then delete it if it is. What is the easiest way to do this? (I am not sure if an "IF" statement is the best way to go or not). Secondly, is there a way to keep the warning pop-up from occurring when trying to delete said sheet? Thanks! |
Locating if a Sheet is present in a workbook
Thank you so much... works like a charm!!
"Don Guillett" wrote: for each ws in worksheets application.displayalerts =false if ws.name="Bad Name" then ws.delete application.displayalerts=true next ws -- Don Guillett Microsoft MVP Excel SalesAid Software "Shane" wrote in message ... Two Part Question: I am looking for code that will locate if a sheet by a specific name is in the workbook, and then delete it if it is. What is the easiest way to do this? (I am not sure if an "IF" statement is the best way to go or not). Secondly, is there a way to keep the warning pop-up from occurring when trying to delete said sheet? Thanks! . |
All times are GMT +1. The time now is 09:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com