'判断当前工作表中是否有隐藏行和/或隐藏列
Sub CheckForHidden()
Dim r As Long
Dim c As Long
Dim booRow As Boolean
Dim booCol As Boolean
Dim strMessage As String
For r = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(r, 1).EntireRow.Hidden = True Then
booRow = True
Exit For
End If
Next r
For c = 1 To ActiveSheet.UsedRange.Columns.Count
If Cells(1, c).EntireColumn.Hidden = True Then
booCol = True
Exit For
End If
Next c
If booRow And booCol Then
strMessage = "工作表中存在隐藏行和隐藏列"
ElseIf booRow Then
strMessage = "工作表中存在隐藏行"
ElseIf booCol Then
strMessage = "工作表中存在隐藏列"
Else
strMessage = "工作表中没有隐藏行或隐藏列"
End If
MsgBox strMessage, vbOKOnly, "结果"
End Sub