Command Button to Open Other Worksheets

kstvns

New Member
Joined
Feb 27, 2011
Messages
20
Using MS Excel 2003 with Win XP OS.

The sheet tabs will not be visible to the user. What is the code to assign to a command button that will open another worksheet in the same workbook? I think this will be better than using creating a hyperlink.

Example: On Sheet A, a click on the command button (named Go to Widgets) will be open Sheet B (Widgets).
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Thanks! How simple that was!

To add to this, I inadvertently pressed F2 and got what I have been looking for all along. :laugh:
 
Upvote 0
In reading other posts with similiar problems, the problems seems to be because I have the sheets hidden. Is there another way for this code to work with the sheets hidden?
 
Upvote 0
Try this

Worksheets("sheet2").Visible = True
Worksheets("sheet2").Activate

Where sheet2 will be your sheet name

George


Using MS Excel 2003 with Win XP OS.

The sheet tabs will not be visible to the user. What is the code to assign to a command button that will open another worksheet in the same workbook? I think this will be better than using creating a hyperlink.

Example: On Sheet A, a click on the command button (named Go to Widgets) will be open Sheet B (Widgets).
 
Upvote 0
Try this

Worksheets("sheet2").Visible = True
Worksheets("sheet2").Activate

Where sheet2 will be your sheet name

George

Thanks, George! That seems to work!!

BTW, is it wise to use the codename of the sheet vs. the sheet name? If so, where would I insert it in the code?
 
Upvote 0
Your welcome

No difference what name you use as long as it is always in "" ""

George

Thanks, George! That seems to work!!

BTW, is it wise to use the codename of the sheet vs. the sheet name? If so, where would I insert it in the code?
 
Upvote 0
You just need to unhide the sheet you want to open, then hide the sheet you were coming from.

like this:

User is on Sheet1 and clicks the button to open Sheet 2:

Sheet2.Visible = True
Sheet2.Activate
Sheet1.Visible = False

Then reverse to go back to Sheet1:

Sheet1.Visible = True
Sheet1.Activate
Sheet2.Visible = False
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

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