Unhide Specific Sheets via Display Box Input

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
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Code:
If (wks.Visible <> xlSheetVisible) And (InStr(wks.Name, TextBox1.Value) > 0) Then
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top