xMIKExSMITHx
New Member
- Joined
- Jul 11, 2014
- Messages
- 45
I have a workbook with quite a few sheets and want to have a text box that displays and asks to enter a text, then the macro will unhide all sheets with that text in it. For instance, if I have sheet names - Work1, Work2, Work3, Data1, Data2, Data3, and only Work1 and Data1 sheets are visable, I want to hit the macro, input text box displays, I type in "Work", and all sheets with "Work" in the title unhide. I have the following but it unhides what is set rather than user input:
Code:
Sub Unhide_Sheets_Contain() Dim wks As Worksheet
Dim count As Integer
count = 0
For Each wks In ActiveWorkbook.Worksheets
If (wks.Visible <> xlSheetVisible) And (InStr(wks.Name, "report") > 0) Then
wks.Visible = xlSheetVisible
count = count + 1
End If
Next wks
If count > 0 Then
MsgBox count & " worksheets have been unhidden.", vbOKOnly, "Unhiding worksheets"
Else
MsgBox "No hidden worksheets with the specified name have been found.", vbOKOnly, "Unhiding worksheets"
End If
End Sub