![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Boston, MA
Posts: 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 |
|
|
|
|
|
#2 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
What happens when you 'Step though' it in debug mode? Are you sure it's not just entering the If statement 8 times?
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|