2015-11-22 31 views
-3

我是新來的,想通過查看專家來學習,並且需要您的幫助來糾正我的代碼。我試圖查看舊數據,但無法獲取任何信息。除了提到的工作表上的運行循環vba

我創建的使用環路中的VBA代碼 - /下一個代碼時,我只用它不需要得到總結類似下面一個工作表名稱這是工作的罰款:

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

With w 
'My code 
End With 

Next 

但是當我試圖使用不需要總結的表格名稱。我在編寫使用數組本身的代碼時出錯,它看起來非常愚蠢,但我幾乎花了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 

如果有人能解決這個問題會有所幫助!

非常感謝,並有一個偉大的週末,你

+0

見:http://www.excelforum.com/excel-programming-vba -macros/1114511 - 運行 - 環 - 上的表-其他超mentioned.html –

回答

0

檢查,如果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 
相關問題