首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Next Next For错误消息

Next Next For错误消息
EN

Stack Overflow用户
提问于 2014-03-13 21:54:32
回答 1查看 117关注 0票数 0

每当我运行下面的代码时,我总是在没有错误消息的情况下得到下一个代码--知道是什么原因导致的吗?

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-13 21:58:55

您还没有关闭您的If语句。您需要一个End If就在您的Next ctr之前。

(顺便说一下,你的压痕对你没有帮助)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22391799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档