Sub 未隐藏工作表数量统计()
Dim n As String
Dim x As String
Dim y As String
n = Worksheets.Count
x = 0
For i = 1 To n
If Worksheets(i).Visible = True Then
x = x + 1
End If
Next
y = MsgBox("当前工作簿中有 " & x & "个未隐藏的工作表", vbOKOnly, "未隐藏工作表数量")
End Sub
dim m as interger
for each worksheet in Worksheets
if worksheet.Visible=xlSheetVisible then
m=m+1
end if
next
反正你看懂里面的意思就好了
检查工作表的Visible属性就知道是否隐藏
Sub Num()
Dim wSH As Worksheet, n
For Each wSH In Sheets
If wSH.Visible Then
n = n + 1
End If
Next
MsgBox "显示状态的工作表个数 = " & n
End Sub
Sub 只统计可见sheet()
For Each ss In Worksheets
If ss.Visible = -1 Then '如果sheet可见开始计数!
k = k + 1
End If
Next ss
MsgBox k
End Sub
注:.Visible = -1这句是关键,-1的值表示可见sheet。
Sub 宏1()
Dim i, t As Integer
For i = 1 To Sheets.Count
If Sheets(i).Visible = True Then
t = t + 1
End If
Next i
Debug.Print t
End Sub