For...Next not looping?

jrnyman

Board Regular
Joined
Mar 10, 2002
Messages
105
Can anyone tell me why this For Next loop does not repeat more than 8 times?

SpreadsRow = 2
For DataRow = 2 To 1309 'defined earlier

Set FDataRow = Range("F" & DataRow)
Set GDataRow = Range("G" & DataRow)
Set ODataRow = Range("O" & DataRow)
Set AspreadsRow = Range("A" & SpreadsRow)
Set BSpreadsRow = Range("B" & SpreadsRow)
Set CSpreadsRow = Range("C" & SpreadsRow)
Set PDataRow = Range("P" & DataRow)


If ODataRow = "Average" Then
If AspreadsRow = "" Then
Range("G" & DataRow).Select
Selection.Copy
Range("A" & SpreadsRow).Select
ActiveSheet.Paste
ElseIf AspreadsRow = GDataRow Then
If FDataRow = "L" Then
Range("P" & DataRow).Select
Selection.Copy
Range("C" & SpreadsRow).Select
ActiveSheet.Paste
ElseIf FDataRow = "B" Then
Range("P" & DataRow).Select
Selection.Copy
Range("B" & SpreadsRow).Select
ActiveSheet.Paste
End If
ElseIf AspreadsRow <> GDataRow Then SpreadsRow = SpreadsRow + 1
End If

End If

Next DataRow
 

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
What happens when you 'Step though' it in debug mode? Are you sure it's not just entering the If statement 8 times?
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,090
Members
448,944
Latest member
sharmarick

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