Macro to select Sheet from List

Brampton76

New Member
Joined
Nov 14, 2008
Messages
35
Greetings,

I have used the following coding in the past to select from 1 of 12 sheets where the sheet has been hidden using one of 12 buttons:

Sub JanuarySheetOpen()
Sheets("January").Visible = True
Sheets("January").Select
Range("A2").Select
End Sub

I now have another workbook where I would like to select from 1 of 89 sheets where the sheets have been hidden (and would like to avoid having 89 separate buttons!). I thought I could use a Data Validation list and refer to the cell as follows:

Sub SheetOpen()
Sheets("Dashboard!H14").Visible = True
Sheets("Dashboard!H14").Select
Range("A2").Select
End Sub

but it would appear not to be the case. I keep running into a 'Runtime Error 9 - Subscript Out of Range' I wonder if someone could point me in the right direction? Also, this may not be the best way to achieve this? Many thanks

Glenn
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try

Code:
Sheets(Sheets("Dashboard").Range("H14")).Visible = xlSheetVisible
 
Upvote 0
Odd. Maybe

Code:
Sheets(Sheets("Dashboard").Range("H14").Value).Visible = xlSheetVisible
 
Upvote 0
Glenn

What are the names of the worksheets?
 
Upvote 0
Many thanks Peter. This works nicely. I ended up with:
Code:
    Sheets(Sheets("Dashboard").Range("H8").Value).Visible = xlSheetVisible
    Sheets(Sheets("Dashboard").Range("H8").Value).Select
    Range("A1").Select
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top