+ Reply to Thread
Results 1 to 6 of 6

Open 'n' Hide

  1. #1
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664

    Open 'n' Hide

    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
    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 rectify this?

    TIA,

    SamuelT

  2. #2
    NickHK
    Guest

    Re: Open 'n' Hide

    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

    "SamuelT" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    > 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 rectify
    > this?
    >
    > TIA,
    >
    > SamuelT
    >
    >
    > --
    > SamuelT
    > ------------------------------------------------------------------------
    > SamuelT's Profile:

    http://www.excelforum.com/member.php...o&userid=27501
    > View this thread: http://www.excelforum.com/showthread...hreadid=552597
    >




  3. #3
    Valued Forum Contributor
    Join Date
    09-23-2005
    Location
    Bristol, UK
    MS-Off Ver
    2007
    Posts
    664
    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

  4. #4
    ikr
    Guest

    Re: Open 'n' Hide

    "SamuelT" <[email protected]> wrote in
    message news:[email protected]...
    >> My remedy would be that you better describe what "Something wrong

    > 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?



  5. #5
    doub_l_helix
    Guest

    Re: Open 'n' Hide

    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.

    ikr wrote:
    > "SamuelT" <[email protected]> wrote in
    > message news:[email protected]...
    > >> My remedy would be that you better describe what "Something wrong

    > > 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?



  6. #6
    ikr
    Guest

    Re: Open 'n' Hide

    "SamuelT" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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!

    > 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 rectify
    > this?
    >
    > TIA,
    >
    > SamuelT
    >
    >
    > --
    > SamuelT
    > ------------------------------------------------------------------------
    > SamuelT's Profile:
    > http://www.excelforum.com/member.php...o&userid=27501
    > View this thread: http://www.excelforum.com/showthread...hreadid=552597
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1