Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if file exists Jon Excel Discussion (Misc queries) 14 October 4th 07 04:57 PM
How to check if a file exists in an ftp folder LL Cool A Excel Discussion (Misc queries) 3 May 16th 06 09:22 PM
check if the sheet/tag exists Alex Excel Worksheet Functions 2 March 14th 06 08:58 PM
check if worksheet exists joeeng Excel Worksheet Functions 3 September 7th 05 06:49 PM
Check if a number exists in a range? gkaste Excel Discussion (Misc queries) 2 July 13th 05 08:00 PM


All times are GMT +1. The time now is 06:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"