Open 'n' Hide

S

SamuelT

Hi all,

I'm trying to run a piece of VB that, on opening the spreadsheet, hide
a number of worksheets and also takes the user to a predefined sheet
Here's what I tried:

Private Sub Workbook_Open()

Sheets("User Select").Activate
Sheets("Programme(High Level)").Visible = xlVeryHidden
Sheets("Programme (2 Week)").Visible = xlVeryHidden
Sheets("Programme (Components").Visible = xlVeryHidden
Sheets("Capacity").Visible = xlVeryHidden
Sheets("Extra Fees Calculator").Visible = xlVeryHidden
Sheets("Control").Visible = xlVeryHidden

End Sub

Something wrong here though...any suggestions what I can do to rectif
this?

TIA,

Samuel
 
N

NickHK

My remedy would be that you better describe what "Something wrong here
though" means.
But at a wild guess, did you match all the brackets ?

NickHK
 
S

SamuelT

Hi,

Yup, all brackets are A-OK now. There was a mistake in there, but I've
rectified it and am still getting the same problem.
My remedy would be that you better describe what "Something wrong
here
though" means.

Better desciption = Run-time error '9':
Subscript out of range

Cheers,

SamuelT
 
I

ikr

SamuelT said:
here
though" means.

Better desciption = Run-time error '9':
Subscript out of range

That probably indicates a sheet name you've specified in your code that
doesn't exist. Have you double-checked the sheet names, including for
rogue/trailing/leading (multiple-)spaces?
 
D

doub_l_helix

I think its the sheet names. If they dont exist in the referenced
workbook then the interpretor will break on that error. I think simpler
naming will suffice.
 
I

ikr

SamuelT said:
Hi all,

I'm trying to run a piece of VB that, on opening the spreadsheet, hides
a number of worksheets and also takes the user to a predefined sheet.
Here's what I tried:

Private Sub Workbook_Open()

Sheets("User Select").Activate
Sheets("Programme(High Level)").Visible = xlVeryHidden
Sheets("Programme (2 Week)").Visible = xlVeryHidden
Sheets("Programme (Components").Visible = xlVeryHidden

shouldn't this line read:

Sheets("Programme (Components)").Visible = xlVeryHidden ???

note the extra close parenthesis after Components. It's somewhat confusing
to look at because you have parentheses in your sheet names!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top