All Sheets Unhide and Select

  • Thread starter Thread starter Hande & Tolga
  • Start date Start date
H

Hande & Tolga

Question 1:
We are missing the visual basic code for selecting all
sheets in the workbook without having specific names for
all the sheets.

Question 2:
We want to unhide all hidden sheets in the workbook
without specifying specific names of them with one line
of code. We have achieved this with for next already but
not with a specific code line.

For Each sh In Sheets
sh.Visible = True
Next sh
 
For your first question, use
Worksheets.Select

For your second question, you need to use the For Next loop. There isn't a
single line of code for unhiding all worksheets.
 
Sub Q1()

Dim wsArray() As String
Dim ws As Worksheet
Dim index As Long

ReDim wsArray(1 To Worksheets.Count)

For index = 1 To Worksheets.Count

wsArray(index) = Worksheets(index).Name

Next

Sheets(wsArray).Select
Sheets("Sheet6").Activate
End Sub

Sub Q2()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Visible = xlSheetVisible
Next
End Sub


Patrick Molloy
Microsoft Excel MVP
 
Back
Top