BDM AT WCS
New Member
- Joined
- Dec 17, 2018
- Messages
- 7
I've got a Workbook report that pulls 'raw' source data in via MS Query. I don't want the report recipients to see this RAW DATA and also some other 'helper' worksheets so I've set those to be VeryHidden. Since there are a large number of other visible sheets, I've copied a macro which produces a list of all sheets, assigns an index number to them and creates hyperlinks for each to quickly navigate around the workbook and reproduces the worksheet colour in the next column. But this macro includes ALL worksheets and I would like to exclude the VeryHidden sheets from the menu. Can anyone help?
VBA Code:
Sub MenuOfSheetsByTab()
'Go to the "menu" worksheet
Sheets("menu").Select
'list all sheets in active workbook
Dim wb As Workbook
Dim ws As Worksheet
Dim wsM As Worksheet
Dim lColorC As Long 'cell color
Dim lColorT As Long 'tab color
Dim lRow As Long
Dim lRowHead As Long
Dim lCol As Long
Dim lCols As Long
Dim lColEnd As Long
Dim lSh As Long
On Error Resume Next
Application.ScreenUpdating = False
Application.EnableEvents = False
Set wb = ActiveWorkbook
Set wsM = Worksheets("menu")
lRowHead = 1
lCol = 1
lCols = 2
lColEnd = lCol + lCols - 1
lRow = lRowHead + 1
With wsM.Range(wsM.Cells(lRowHead, lCol), _
wsM.Cells(lRowHead, lColEnd))
.EntireColumn.Clear
.Value = Array("ID", "Sheet")
End With
With wsM
For Each ws In wb.Worksheets
.Range(.Cells(lRow, lCol), _
.Cells(lRow, lColEnd - 1)).Value _
= Array(lRow - lRowHead, ws.Name)
If ws.Tab.ColorIndex = -4142 Then
.Cells(lRow, lColEnd) _
.Interior.ColorIndex _
= ws.Tab.ColorIndex
Else
.Cells(lRow, lColEnd) _
.Interior.Color _
= ws.Tab.Color
End If
'add hyperlink to sheet name
.Hyperlinks.Add _
Anchor:=.Cells(lRow, lCol + 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1", _
ScreenTip:=ws.Name, _
TextToDisplay:=ws.Name
lRow = lRow + 1
Next ws
With .Range(.Cells(lRowHead, lCol), _
.Cells(lRowHead, lColEnd))
.Font.Bold = True
.EntireColumn.AutoFit
End With
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub