Activating Hidden Worksheets From Combo Box Selections

davidhall

Board Regular
Joined
Mar 6, 2011
Messages
174
I have a combo box that has several names in it for the user to select. Based on what they select, for instance, the name Jennifer, then a hidden worksheet should appear. The title of the worksheet that should appear is the employees name. Any suggestions?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
18,069
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Assuming your combo box is named ComboBox1 (change to suit) and is an Active-X control:
Code:
Private Sub ComboBox1_Change()
Dim shtNam As String
shtNam = ComboBox1.Text
ThisWorkbook.Sheets(shtNam).Visible = True
End Sub
 
Upvote 0

davidhall

Board Regular
Joined
Mar 6, 2011
Messages
174
Thanks. Couple quick questions. Will that still work if its not an active x control? Also, if the selected name from the combo box is the name and the sheet name is Sheet1 for person A and Sheet2 for person B, how can I make that work so that I don't have to change the multiple worksheets to correspond to the persons name? I can setup two columns side by side with row A listing the persons name and row B stating the corresponding worksheet.
 
Upvote 0

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
18,069
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
If you use a forms control rather than an Active-X control, then you can't use the change event to trigger making the sheet visible. If you don't want to name the sheets after the employees you can create a look-up table as you suggested and use something like this in the code:
Code:
Dim lkuprng as range
set lkuprng = Range("your look-up range between these quotes")
' previous code
shtNam =worksheetfunction.VLookup(ComboBox1.Text,lkuprng,2,0)
'previous code
 
Upvote 0

Forum statistics

Threads
1,191,500
Messages
5,986,921
Members
440,067
Latest member
Swatts1

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
Top