Sub ListHiddenRowsAndColumns()
Dim rngBlankCol As Excel.Range, _
rngBlankRow As Excel.Range, _
rngHidden As Excel.Range, _
rngUsed As Excel.Range, _
rngVis As Excel.Range, _
strAddress As String, _
strColLetter As String, _
strMsg As String, _
wf As Excel.WorksheetFunction
Application.ScreenUpdating = False
Set rngUsed = ActiveSheet.UsedRange
Set rngBlankCol = Range("A1").Offset(, rngUsed.Columns.Count + 2).Resize(, 1).EntireColumn
Set rngBlankRow = Range("A1").Offset(rngUsed.Rows.Count + 2).Resize(1).EntireRow
'// count hidden columns
On Error Resume Next
Set rngVis = rngBlankRow.SpecialCells(xlCellTypeVisible)
If rngVis.Count = rngBlankRow.Cells.Count Then
strMsg = "Hidden Columns: none" & vbCr & vbCr
Else
rngBlankRow.Formula = "1"
rngVis.Clear
Set rngHidden = rngBlankRow.SpecialCells(xlCellTypeConstants, XlSpecialCellsValue.xlNumbers)
Let strAddress = rngHidden.Address(0, 0)
Let strAddress = Replace(strAddress, CStr(rngBlankRow.Row), "")
Let strMsg = "Hidden Columns: (" & rngHidden.Count & ") " & strAddress & vbCr & vbCr
End If
rngBlankRow.Clear
'// count hidden rows
On Error Resume Next
Set rngVis = rngBlankCol.SpecialCells(xlCellTypeVisible)
If rngVis.Count = rngBlankCol.Cells.Count Then
strMsg = strMsg & "Hidden Rows: none"
Else
rngBlankCol.Formula = "1"
rngVis.Clear
Set rngHidden = rngBlankCol.SpecialCells(xlCellTypeConstants, XlSpecialCellsValue.xlNumbers)
Let strAddress = rngHidden.Address(0, 0)
Let strColLetter = rngBlankCol.Address
Let strColLetter = Replace(strColLetter, "$", "")
Let strColLetter = Left(strColLetter, InStr(1, strColLetter, ":") - 1)
Let strAddress = Replace(strAddress, strColLetter, "")
Let strMsg = strMsg & "Hidden Rows: (" & rngHidden.Count & ") " & strAddress & vbCr & vbCr
End If
rngBlankCol.Clear
MsgBox strMsg, vbInformation
End Sub