Excel 在除上述vba以外的图纸上运行循环

Excel 在除上述vba以外的图纸上运行循环,excel,for-loop,vba,Excel,For Loop,Vba,我是新来的,试图通过专家学习,需要您的帮助来纠正我的代码。我试图查看旧数据,但无法获得任何信息 我已经使用loop-For/next代码创建了一个vba代码,当我只使用一个工作表名称时,该代码运行良好,无需如下总结: For Each w In Worksheets If w.Name <> "Summary" Then With w 'My code End With Next 工作表中每个w的 如果w.名称为“摘要”,则 与w “我的代码 以 下一个 但当我尝试使用带有工

我是新来的,试图通过专家学习,需要您的帮助来纠正我的代码。我试图查看旧数据,但无法获得任何信息

我已经使用loop-For/next代码创建了一个vba代码,当我只使用一个工作表名称时,该代码运行良好,无需如下总结:

For Each w In Worksheets
If w.Name <> "Summary" Then

With w
'My code
End With

Next
工作表中每个w的

如果w.名称为“摘要”,则
与w
“我的代码
以
下一个
但当我尝试使用带有工作表名称的数组时,不需要对其进行汇总。我在使用数组本身编写代码时出错,这看起来很愚蠢,但我几乎花了8天的时间来找出我做错了什么,如果您能纠正我的错误,那将非常有帮助:

使用的代码

For Each w In Worksheets

If w.Name <> Array("Summary", "Not Certified", "STAT Reconciliations", "Blank Account#", "Blank Description", "Blank Line#", "Blank Reference", "Prepd Rec's-Unidentified Bal>1", "Preparere Unassigned", "Approver Unassigned", "Reviewer Unassigned", "Acct Reviewer Unassigned", "Acct Owner Unassigned", "Key should be Non-Key", "Non-Key should be Key", "Blank Risk Rating", "Timelines", "Recon WorkFlow") Then

With w

My code
End With
Next
工作表中每个w的

如果w.名称数组(“摘要”、“未认证”、“统计对账”、“空白账户”、“空白说明”、“空白行”、“空白参考”、“预记录-未识别余额>1”、“预记录未分配”、“审批人未分配”、“审核人未分配”、“账户审核人未分配”、“账户所有者未分配”、“关键字应为非关键字”、“非关键字应为关键字”,“空白风险评级”、“时间表”、“侦察工作流程”)然后
与w
我的代码
以
下一个
如果有人能解决这个问题,那会很有帮助的


非常感谢,祝大家周末愉快

检查sh是否在阵列中

    Sub LookSheets()
    Dim sh As Worksheet
    Dim Arr As Variant
    Dim NotSH(0 To 15) As String
    Dim F As Boolean

    'Array of Sheet Names you don't want to use
    NotSH(0) = "Summary"
    NotSH(1) = "Not Certified"
    NotSH(2) = "STAT Reconciliations"
    NotSH(3) = "Blank Account#"
    NotSH(4) = "Blank Description"
    NotSH(5) = "Blank Line#"
    NotSH(6) = "Blank Reference"
    NotSH(7) = "Prepd Rec's-Unidentified Bal>1"
    NotSH(8) = "Preparere Unassigned"
    NotSH(9) = "Reviewer Unassigned"
    NotSH(10) = "Acct Owner Unassigned"
    NotSH(11) = "Key should be Non-Key"
    NotSH(12) = "Non-Key should be Key"
    NotSH(13) = "Blank Risk Rating"
    NotSH(14) = "Timelines"
    NotSH(15) = "Recon WorkFlow"


    For Each sh In Sheets   'loop through sheets
        F = False
        For Each Arr In NotSH   'NotSH=sh.name?
            If sh.Name = Arr Then    'If it is, set F =true
                F = True
                Exit For
            End If
        Next Arr
        If F = False Then    'if not found then do something in the sheet
            MsgBox sh.Name
        End If
    Next sh

End Sub
见: