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?
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?