如果不是在多种条件下都没有

时间:2015-02-23 21:40:43

标签: excel vba excel-vba

有人可以帮我在这里找到错误吗?

If Not r Is Nothing Then
    r.Select
Else
If Not rr Is Nothing Then
    rr.Select
Else
If Not rrr Is Nothing Then
    rrr.Select
Else
End If

1 个答案:

答案 0 :(得分:5)

您的代码存在的问题是,您使用的是If Else If而不是If ElseIf,您需要执行以下操作:

If Not r Is Nothing Then
    r.Select
Else
    If Not rr Is Nothing Then
        rr.Select
    Else
       If Not rrr Is Nothing Then
           rrr.Select
       Else
       End If
    End If
 End If

或者

If Not r Is Nothing Then
    r.Select
ElseIf Not rr Is Nothing Then
    rr.Select
ElseIf Not rrr Is Nothing Then
    rrr.Select
Else
End If

第二个可能更好。