Command Button to show/hide a different worksheet

  • Thread starter Thread starter Marilyn
  • Start date Start date
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
 
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
 
Back
Top