0
每當我運行下面的代碼,我不斷收到下一個沒有錯誤信息 - 任何想法可能會導致它?Next沒有對於錯誤消息
Sub VDA_Update()
Dim wshT As Worksheet
Dim wbk As Workbook
Dim wshS As Worksheet
Dim r As Long
Dim m As Long
Dim cel As Range
Application.ScreenUpdating = False
Set wshT = ThisWorkbook.Worksheets("Master")
On Error Resume Next
' Check whether vda.xlsx is already open
Set wbk = Workbooks("vda.xlsx")
On Error GoTo 0
If wbk Is Nothing Then
' If not, open it
Set wbk = Workbooks.Open("C:\Working\vda.xlsx")
End If
' Set worksheet on vda.xlsx
Set wshS = wbk.Worksheets("remotepclist")
m = wshT.Cells(wshT.Rows.Count, 1).End(xlUp).Row
' Loop though cells in column J on main.xlsm
For r = 1 To m
For cCtr = 0 To 2
' Can we find the value in column A of vda.xlsx?
Set cel = wshS.Columns(1).Find(What:="EMEA\" + wshT.Cells(r, 10 + cCtr).Value, _
LookAt:=xlWhole, MatchCase:=False)
If Not cel Is Nothing Then
' If we find a match, then change cell color
If cel.Offset(0, 1).Value = "TRUE" Then
wshT.Cells(r, 10 + cCtr).Interior.ColorIndex = 15
ElseIf cel.Offset(0, 1).Value = "FALSE" Then
wshT.Cells(r, 10 + cCtr).Interior.ColorIndex = 6
If wshT.Cells(r, 15).Value = "" Then wshT.Cells(r, 15).Value = "Yes"
If wshT.Cells(r, 16).Value = "" Then wshT.Cells(r, 16).Value = "5.6.200"
End If
Next cCtr
Next r
Application.ScreenUpdating = True
End Sub
在'Next cCtr'之前加上'End If' –
您在最後一個循環中缺少** endif ** – Alex
我修復了代碼中的縮進。現在應該很明顯了。 – Floris