Command Button to show/hide a different worksheet

M

Marilyn

Hello I have several command buttons in a worksheet. each command button
selects a different worksheet. Each worksheet has a different form .
Example
Private Sub CommandButton5_Click()
Worksheets("Application").Activate
End Sub

What I want to do is if the command button "application" is selected to
open the worksheet "application" and the other worksheets to be hidden.
thanks in advance
 
P

Per Jessen

Hello

I assume your "MainSheet" should always be visible. Try this:

Private Sub CommandButton5_Click()
For Each sh In ThisWorkbook.Sheets
If sh.Name <> "MainSheet" Then
sh.Visible = False
End If
Next
With Worksheets("Application")
.Visible = True
.Activate
End With
End Sub

Regards,
Per
 

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