Macro to show message if any sheets are hidden

dlz217

New Member
Joined
Aug 23, 2013
Messages
49
Hi. I'm trying to just create a msgbox if there are any sheets hidden in the workbook. (This is part of a longer series of steps, so I want this prompt as a check.)

Thanks.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
This should work:

Code:
Private Sub ReportVisibility()   'List very hidden sheets in Immediate window   
Dim ws As Worksheet   
For Each ws In ThisWorkbook.Worksheets     
	If ws.Visible = xlSheetVeryHidden Then       
		Debug.Print ws.Name & " is very hidden"     
	ElseIf ws.Visible = xlSheetHidden Then       
		Debug.Print ws.Name & " is hidden"     
	End If 
Next 
End Sub
 
Upvote 0
Maybe:
Code:
Sub dlz217()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    For Each ws In Sheets
        If ws.Visible = xlSheetVeryHidden Or ws.Visible = xlSheetHidden Then
            MsgBox (ws.Name & " is hidden.")
        End If
    Next ws
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Try this:
Code:
Sub check_If_Hidden()
Application.ScreenUpdating = False
Dim i As Long
Dim ans As String
    For i = 1 To Sheets.Count
    If Sheets(i).Visible = False Then ans = ans & Sheets(i).Name & vbNewLine
    Next
    If ans <> "" Then MsgBox "These sheets are hidden" & vbNewLine & ans
    If ans = "" Then MsgBox "There are no hidden sheets"
    
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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