[英]Loop through all but four sheets in a workbook
我有 15 張紙,其中我需要遍歷除名為 graphs、print、summary 和 print 的四張紙之外的所有紙。
我的代碼只排除第一個工作表而不是其他三個。
Dim Current As Worksheet
For Each Current In Worksheets
If Current.Name <> "Summary" And Current.Name <> "Model" And Current.Name <> "Print" And Current.Name <> "Graphs" Then
MsgBox Current.Name
Next
End Sub
我希望能夠排除輸出中的四張紙。 TIA
這應該有效:
Sub whatever()
Dim Current As Worksheet, c As String
For Each Current In Worksheets
c = Current.Name
If c <> "Summary" And c <> "Model" And c <> "Print" And c <> "Graphs" Then
MsgBox c
End If
Next
End Sub
Sub Sheets_Walk()
Dim ws As Worksheet
For Each ws In Worksheets
If s_in_A1(ws.Name, a1_Names) = False Then
MsgBox ws.Name
End If
Next
End Sub
Function s_in_A1( _
s As String, _
a1 As Variant) _
As Boolean
Dim lCol As Long
For lCol = LBound(a1) To UBound(a1)
If a1(lCol) = s Then
s_in_A1 = True
Exit For
End If
Next
End Function
Function a1_Names() _
As Variant
a1_Names = Array("Summary", "Model", "Print", "Graphs")
End Function
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.