How do I set a macro to unhide a worksheet and stay on it?

M

moez77

I am trying to create a form on Excel (2007) that will contain individual
form control buttons for every worksheet in the workbook. My goal is to just
display one sheet with a control button with all the options for the actual
worksheets. Once the user selects the button for the worksheet he would like
to see that worksheet should unhide and display. I got the macro recorded to
do so but it then switches back to the form sheet. I would like for it to
remain on the newly displayed worksheet.
 
J

JLGWhiz

Assuming sheet 2 is hidden, the something like:

Private Sub CommandButton1_Click()
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Activate
End Sub
 
J

JLGWhiz

If the button is on a UserForm, modify the code to:

Private Sub CommandButton1_Click()
Sheets("Sheet2").Visible = True
Sheets("Sheet2").Activate
Unload Me
End Sub

This will close the UserForm and leave the Active sheet on screen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top