D
darkman
Hi,
I am having an issue with a For Next loop where the current loop value
seems to be incrementing before getting to "Next".
Basically I want to loop through a number of periods (months) picking
up any rows that have a date that falls within the current period. The
code seems to work fine but for some reason it jumps from X1 = 1 to X1
= 2 or X1 = 3 before getting to Next - which means it is missing
picking up any data for those months.
Any ideas?
Thanks
My Code --->
For X1 = 1 To cboPeriods
If Not IsEmpty(ActiveCell.Value) Then
Date3 = DateAdd("m", 1, Date2)
Date4 = DateAdd("d", -1, Date3)
Do Until IsEmpty(ActiveCell.Value)
Date1 = ActiveCell.Value
If Date1 >= Date2 And Date1 < Date4 Then
dblThisJob = ActiveCell.Offset(0, 3).Value
Call PerformCalc(Date1, X1, ActiveCell.Value, dblThisJob)
End If
ActiveCell.Offset(1, 0).Select
Loop
Else
' ## due to either there being no job/change requests or the first
job/change request
' ## is listed in cell 'A3'
MsgBox "Error: There is no Job/Change Request listed in cell 'A2'.
There must be a value in this first cell", vbCritical
End If
Date2 = DateAdd("m", 1, Date2)
Application.Goto (Worksheets("ChangeRequests").Range("A2"))
Next X1
End Code --->
I am having an issue with a For Next loop where the current loop value
seems to be incrementing before getting to "Next".
Basically I want to loop through a number of periods (months) picking
up any rows that have a date that falls within the current period. The
code seems to work fine but for some reason it jumps from X1 = 1 to X1
= 2 or X1 = 3 before getting to Next - which means it is missing
picking up any data for those months.
Any ideas?
Thanks
My Code --->
For X1 = 1 To cboPeriods
If Not IsEmpty(ActiveCell.Value) Then
Date3 = DateAdd("m", 1, Date2)
Date4 = DateAdd("d", -1, Date3)
Do Until IsEmpty(ActiveCell.Value)
Date1 = ActiveCell.Value
If Date1 >= Date2 And Date1 < Date4 Then
dblThisJob = ActiveCell.Offset(0, 3).Value
Call PerformCalc(Date1, X1, ActiveCell.Value, dblThisJob)
End If
ActiveCell.Offset(1, 0).Select
Loop
Else
' ## due to either there being no job/change requests or the first
job/change request
' ## is listed in cell 'A3'
MsgBox "Error: There is no Job/Change Request listed in cell 'A2'.
There must be a value in this first cell", vbCritical
End If
Date2 = DateAdd("m", 1, Date2)
Application.Goto (Worksheets("ChangeRequests").Range("A2"))
Next X1
End Code --->