show hide sheets excel in VBA
I am currently working on a spreadsheet that tracks data for about 40 employees. As you can tell the worksheet tabs become quite cumbersome to sort through, so I was wondering if I could write code to assign each tab (worksheet) to an employee. I thought that If I could create a main page with a button for each employee, then I could just click the button to go right to their worksheet, all while keeping the other tabs (worksheets) hidden. I tried the following formula and instructions but don't understand what it means when it says "edit the commandbutton10 to match the numeric value of your new button so it works....edit all references" I Shouldn't the code just be written specifially to the button created? Any help would be appreciated.
1. Use the Control Toolbox toolbar to create a Command Button.
2. Right-click the new button, and select Properties
3. Put a new CAPTION called TURN FEB OFF
4. Close the Properties Window
5. Now, let's have some fun: Right-click the new button again and select View Code
6. A blinking cursor is ready for your new code. Add the code below:
Code:
Application.ScreenUpdating = False
If CommandButton10.Caption = "TURN FEB OFF" Then
CommandButton10.Caption = "TURN FEB ON"
CommandButton10.ForeColor = &HFFFF&
Sheets("FEB").Visible = False
Else: CommandButton10.Caption = "TURN FEB OFF"
CommandButton10.ForeColor = &HC0&
Sheets("FEB").Visible = True
7. Edit the CommandButton10 to match the numeric value of your new button so it works... edit all the references.
8. Now click the Exit Design Mode button on the Control Toolbox toolbar.
9. Try clicking your new button
If this works to your satisfaction, edit the VBA above to do all the sheets, or make individual buttons. Your call.