Robert_Conklin
Board Regular
- Joined
- Jun 19, 2017
- Messages
- 173
- Office Version
- 365
- Platform
- Windows
- MacOS
Good evening, I have the below sub that is set to hide all Tabs with a name that ends in h. I would like to modify it to use the same button to Hide/Unhide all tabs that contain a word instead of ends with a letter.
Any help would be greatly appreciated!!
VBA Code:
Option Explicit
'Set tab naming convention to hide & unhide
Const TABNAME As String = "-h"
Sub Hide_Named_Sheets()
'Hide all sheets that end with -h
Dim ws As Object 'Use object instead of worksheet for Chartsheets
'Hide sheets with sheet name ending in -h
For Each ws In ActiveWorkbook.Sheets
If Right(ws.Name, 2) = TABNAME Then
ws.Visible = xlSheetHidden
End If
Next ws
End Sub
Any help would be greatly appreciated!!