ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Command Button to show/hide a different worksheet (https://www.excelbanter.com/excel-discussion-misc-queries/228437-command-button-show-hide-different-worksheet.html)

Marilyn

Command Button to show/hide a different worksheet
 
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


Per Jessen[_2_]

Command Button to show/hide a different worksheet
 
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


On 22 Apr., 03:42, Marilyn wrote:
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




All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com