0

I made a nested For loop as shown:

For i = 1 To 14
Set curCell_a = Worksheets("Sheet1").Cells(i, 6)    

If curCell_a.Value = 100 Then
Set curCell_b = curCell_a.Offset(3, -1)
cRow = curCell_b.Row     

For j = cRow To 15
Set curCell_c = Worksheets("Sheet1").Cells(cRow, 5)
While curCell_c.Font.Bold = False
MsgBox (curCell_c.Value)
End

Next j    
End If    
Next i

Yet I keep getting the error Compile error: Next without For

I am fairly sure I put the Next j, End If, and Next i in the logical order... Can someone please help me? Thank you so much!

2 Answers 2

1

I think the problem is with the End statement: it should be Wend (While-End).

For i = 1 To 14

    Set curCell_a = Worksheets("Sheet1").Cells(i, 6)

    If curCell_a.Value = 100 Then

        Set curCell_b = curCell_a.Offset(3, -1)
        cRow = curCell_b.Row

        For j = cRow To 15
            Set curCell_c = Worksheets("Sheet1").Cells(cRow, 5)
            While curCell_c.Font.Bold = False
                MsgBox (curCell_c.Value)
            Wend
        Next j

    End If

Next i

See http://office.microsoft.com/en-us/excel-help/HV080557576.aspx

Sign up to request clarification or add additional context in comments.

Comments

0

A while block needs to be ended with Wend, not End. The compiler's not seeing the end of that block.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.