每当我运行下面的代码时,我总是在没有错误消息的情况下得到下一个代码--知道是什么原因导致的吗?
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发布于 2014-03-13 21:58:55
您还没有关闭您的If语句。您需要一个End If就在您的Next ctr之前。
(顺便说一下,你的压痕对你没有帮助)。
https://stackoverflow.com/questions/22391799
复制相似问题