Macro to Show hidden sheet

djossh

Board Regular
Joined
Jul 27, 2009
Messages
243
Hi i need a macro or vba code for this..

I have a workbook with "Hidden" sheet1, sheet2, sheet3 & sheet4....i also have userform (auto open everytime i open my workbook) with dropdown list namely Selection1, Selection2, Selection3 & Selection4...

what i want is if i select "Selection1" on the dropdown list it should show the sheet1 only... if i select "Selection3" on the dropdown list it should open my sheet3 and same with other Selection list..

Only 1 (one) sheet should be open.. everytime i switch to other sheet the current open sheet should be hidden..thanks..
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Adapt this to suit;
Code:
Sub HideSheet()
Sheets("Sheet1").Visible = True
Sheets("Sheet2").Visible = False
Sheets("Sheet3").Visible = False
Sheets("Sheet4").Visible = False
End Sub

HTH
Colin
 
Upvote 0
Hi i need a macro or vba code for this..

I have a workbook with "Hidden" sheet1, sheet2, sheet3 & sheet4....i also have userform (auto open everytime i open my workbook) with dropdown list namely Selection1, Selection2, Selection3 & Selection4...

what i want is if i select "Selection1" on the dropdown list it should show the sheet1 only... if i select "Selection3" on the dropdown list it should open my sheet3 and same with other Selection list..

Only 1 (one) sheet should be open.. everytime i switch to other sheet the current open sheet should be hidden..thanks..

You can use case select

Rich (BB code):
selection = range("whatever cell your drop down list relates to").value
select case selection
case selection1
Sheets("selection1").Visible = True
Sheets("selection2").Visible = False
Sheets("selection3").Visible = False
Sheets("selection4").Visible = False
case selection2
Sheets("selection1").Visible = False
Sheets("selection2").Visible = True
Sheets("selection3").Visible = False
Sheets("selection4").Visible = False
case selection3
Sheets("selection1").Visible = False
Sheets("selection2").Visible = False
Sheets("selection3").Visible =True
Sheets("selection4").Visible = False
case selection4
Sheets("selection1").Visible = False
Sheets("selection2").Visible = False
Sheets("selection3").Visible = False
Sheets("selection4").Visible = True
end select
 
Upvote 0
Hi. thank you for your quick reply.. i just have one more question... what if i used the sheet name in my drop down list instead of using other name.. or is it possible to auto generate the dropdown list everytime i add new sheet since im using the sheet name as my drop down list also??... if that is possible please post the code.. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
Members
452,939
Latest member
WCrawford

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