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.
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
You are missing an End Select

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

Watch MrExcel Video

Forum statistics

Threads
1,123,045
Messages
5,599,488
Members
414,313
Latest member
Oonagh123

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
Top