For...Next not looping?
VBA Telemetry pings you when your VBA projects fail
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: For...Next not looping?

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Milwaukee, WI
    Posts
    105
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    What happens when you 'Step though' it in debug mode? Are you sure it's not just entering the If statement 8 times?

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com