Error with nested For...Next statements

jrfeni

New Member
Joined
Jun 27, 2005
Messages
18
When I try to run the following code, I get a "Next without For" error:

Sub update()

Dim i As Long
Dim j As Long
Dim rcount As Long
Dim Ws As Worksheet

For i = 1 To 12
Worksheets("Lookup").Cells(2, 3).Value = i
If i <= 9 Then
Set Ws = Sheets("LL0" & i)
ElseIf i = 12 Then
Set Ws = Sheets("LL14")
Else
Set Ws = Sheets("LL" & i)
With Ws
.Range("a4:c368").Clear
End With
For j = 1 To 3
rcount = Worksheets("Reference").Range.Cells(i, 3)
Worksheets("Lookup").Cells(5, 2).Value = j
Range("lookup_range").Copy
With Ws
.Cells(rcount, 1).PasteSpecial Paste:=xlPasteValues
End With
Next j
Next i

End Sub


Sorry if the formatting sucks. Can anyone tell me what the problem is?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,136,262
Messages
5,674,708
Members
419,520
Latest member
Jennifer4Dillon

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