• If Then Else not working (VBA for Word 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » If Then Else not working (VBA for Word 2000)

    Author
    Topic
    #363616

    The following is an excerpt of code from the ATTACHED document. I’m having problems with an If/Then/Else. After running through several paragraphs the Else should be activated, but it is not. The “less than (<)" should be false when K=UBound(ListFormatArray, 1), but it is showing as true. Thanks for any help you can give!! Troy

    For K = 1 To UBound(ListFormatArray, 1)
    'CHECK OUT THESE VALUES. AFTER THE FIRST RUN THROUGH THEY ARE EQUAL.
    MsgBox UBound(ListFormatArray, 1)
    MsgBox K
    If ExistingNumberStyle ListFormatArray(K, 1) Or _
    ExistingNumberFormat ListFormatArray(K, 2) Or _
    ExistingParagraphIndent ListFormatArray(K, 3) Then
    If FirstRowInArray = True Then
    GoTo MoveToFirstRowInArray
    End If
    ‘THIS IS THE LINE OF CODE THAT DOES NOT SEEM TO WORK. AS YOU CAN SEE _
    FROM THE MESSAGE BOXES ABOVE, K=1 and UBound(ListFormatArray, 1)=1 _
    SO THE “IF” SHOULD GO TO THE “ELSE”, BUT THE IF IS COMING ACROSS AS TRUE.
    If K < UBound(ListFormatArray, 1) Then
    End If
    Else

    Viewing 0 reply threads
    Author
    Replies
    • #555437

      You have the End If immediately after the If. That terminates that If statement, and the Else after that End If goes with the first In in the code you showed. Since there are no statements in the If to execute, it is tough to know if the condition was True or False.

      • #555443

        Believe it or not, the problem was another “End If” that I had commented out. If found it after moving a large block of code within this procedure to its own procedure.

        I hate it when it’s something simple.

        Thanks for responding!!
        Troy brickwall

    Viewing 0 reply threads
    Reply To: Reply #555443 in If Then Else not working (VBA for Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel