Stan, what is your criteria to determine which sheet will be visible?
BarrieBarrie Davidson
Barrie
I have a UserForm as a Main Menu. When it is showing, the WorkBook is hidden. When a selection is made from the menu, the WorkBook is shown and a particular worksheet is "activated" and made visible (all other sheets are hidden). When I return to the Main Menu the Workbook is hidden again. Say I choose another menu item. The WorkBook is activated again and I want another Worksheet to be visible - but I also want the other worksheets hidden (e.g. the one I had previously viewed). Is this clear?
Stan
Stan, I think the following code will do what you require. It assumes that you will declare the sheet name to unhide via a variable named "unhideName" and then it will cycle through all the sheets making sure that there is only one sheet visible.
Dim count As Integer, counter As Integer
Dim unhideName As String
'Your code to get sheet name
Sheets(unhideName).Visible = True
count = ActiveWorkbook.Sheets.count
For counter = 1 To count
If Sheets(counter).Name <> unhideName Then Sheets(counter).Visible = False
Next counter
' the rest of your code
Hope this is what you need.
Regards,
Barrie
Barrie Davidson