Compile error: End If without block If

后端 未结 1 823
抹茶落季
抹茶落季 2020-12-18 12:04

I am currently running the below loop to pull out information from another spreadsheet, but keep getting the following error message Compile error: End If without bl

相关标签:
1条回答
  • 2020-12-18 13:06

    Further to my comments above, change your code to

    If Not cel Is Nothing Then
        If cel.Offset(0, 8).Value = "Yes" Then wshT.Cells(r, 14).Value = "Virtual"
        If cel.Offset(0, 8).Value = "" Then wshT.Cells(r, 14).Value = "Physical"
    End If
    

    or to this

    If Not cel Is Nothing Then
        If cel.Offset(0, 8).Value = "Yes" Then
            wshT.Cells(r, 14).Value = "Virtual"
        ElseIf cel.Offset(0, 8).Value = "" Then
            wshT.Cells(r, 14).Value = "Physical"
        End If
    End If
    

    For the syntax of IF/EndIf, see the below

    '~~> Multiple-line syntax:
    If condition [ Then ]
        [ statements ]
    [ ElseIf elseifcondition [ Then ]
        [ elseifstatements ] ]
    [ Else
        [ elsestatements ] ]
    End If
    
    '~~> Single-line syntax:
    If Condition Then [ statements ] [ Else [ elsestatements ] ]
    
    0 讨论(0)
提交回复
热议问题