![]() |
check if sheet exists
Hi,
I have a lot of workbooks with same structure which I unprotect with a macro in personal.xls. However some have one worksheet less, called "FTE" How can I test in this macro if a worksheet exists and if so unprotect it and if not goto next line. Cheers, Harold |
check if sheet exists
dim TestWks as worksheet
set testwks = nothing on error resume next set testwks = activeworkbook.worksheets("fte") on error goto 0 if testwks is nothing then 'it ain't there else 'unprotect it end if ====== It may be simpler to just ignore the error when you try to unprotect it: on error resume next activeworkbook.worksheets("Fte").unprotect password:="hi there" on error goto 0 mohavv wrote: Hi, I have a lot of workbooks with same structure which I unprotect with a macro in personal.xls. However some have one worksheet less, called "FTE" How can I test in this macro if a worksheet exists and if so unprotect it and if not goto next line. Cheers, Harold -- Dave Peterson |
All times are GMT +1. The time now is 05:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com