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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,174
Messages
6,123,454
Members
449,100
Latest member
sktz

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