For/Next loop error

Titian

Well-known Member
Joined
Dec 17, 2004
Messages
567
I am getting a "Next without For" compile error with the following extract of code. Is it due to the "Case" statement within the loop?

Code:
For i = 148 To 162
        accounts = Cells(i, 15)
        Select Case accounts
            Case Is >= 150: If Cells(i, 19).Value = 150 Then Cells(i, 18).Value = 150 Else _
                Cells(i, 18).Value = Cells(i, 19).Value + 10
            Case 100 To 149
                If Cells(i, 19).Value = 100 Then
                    Cells(i, 18).Value = 100
                        Else: If Cells(i, 19).Value > 50 Then Cells(i, 18).Value = Cells(i, 19).Value + 5 Else _
                        Cells(i, 18).Value = Cells(i, 19).Value + 10
                End If
            Case Else
    Next i

Any help appreciated, thanks.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You are missing an End Select

Rich (BB code):
          Case Else
    End Select
Next i
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top