LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Hierarchy of Codename and error catching if no worksheet.

Hi all,
Using Excel2003/2007 with Win XP/Vista.

I have a userform which has a number of checkboxes to tick to show up
the appropriate worksheets. ie to lessen clutter per individual user
preference.

Within my commandOK_click button i have the following code:
If chkSh01 then Sh01.visible = xlSheetVisible else
Sh01.visible=xlSheetVeryHidden
If chkSh02 then Sh02.visible = xlSheetVisible else
Sh02.visible=xlSheetVeryHidden
....
If chkSh30 then Sh30.visible = xlSheetVisible else
Sh30.visible=xlSheetVeryHidden
etc
to 30 sheets.

Sh01, Sh02 ... thru to Sh30 refers to sheet property codename.
Primarily to allow user change the name via the sheet tab AND also to
allow delete of sheets but not add.

If all the 30 sheets are there then the code works okay.
But if one or more sheets are not there then the code fails with a
compile error: "Variable not found".

Qn: 1. how do i code so that if the sheet does not exist then that
the error is ignored. What error catching routine can i use.
Qn: 2. to avoid the "variable not found" i need to reference the Sh01
properly so that VBA knows its refering to a sheet object.

I have to use the sheet codename as this is predetermined at design
stage with the names Sh01 to Sh30 thus allowing the user to change tab
name, delete the sheets but not add.

Still learning and enjoying...Many thanks
Rgds
Kieranz
 
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
Catching edit mode error c mateland Excel Programming 2 June 9th 07 07:09 AM
Catching an error ChrisMattock[_29_] Excel Programming 8 July 4th 06 10:15 AM
Worksheet Codename - Crazy Method Error! EphesiansSix Excel Programming 4 June 24th 06 01:52 AM
globally catching any error event? RB Smissaert Excel Programming 2 August 4th 05 07:16 PM
Catching an error Shannon Excel Programming 1 December 8th 03 08:22 PM


All times are GMT +1. The time now is 01:20 AM.

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"