Do Until Loop

  • Thread starter Thread starter sgl
  • Start date Start date
S

sgl

I have the following

1 - A Start Date
2 - This Date must be incremented by a certain period (months, quarters,
semi-annualy etc) each time the Loop passes
3 - Need to write the result into a range
4 - "Max range" to write this in is 100 rows (calculated bewteen two ranges
- say A1:A100). loop must stop at 100.

Can someone help write this simple code for me
tanhks/sgl
 
Taking a course?

Sub DateIncrementSample()
Dim i As Integer
Dim rtnDate As Date
Dim stDate As Date

stDate = #1/1/2000#
rtnDate = stDate

i = 1
Do Until i > 100

rtnDate = DateAdd("d", 1, rtnDate)

Range("A" & i).Value = rtnDate

i = i + 1

Loop

End Sub

'After DateAdd("

'yyyy = Year
'q = Quarter
'm = Month
'y = Day of year
'd = Day
'w = Weekday
'ww = Week
'h = Hour
'n = Minute
's = Second
 
Thank you for assistance that worked for me

AltaEgo said:
Taking a course?

Sub DateIncrementSample()
Dim i As Integer
Dim rtnDate As Date
Dim stDate As Date

stDate = #1/1/2000#
rtnDate = stDate

i = 1
Do Until i > 100

rtnDate = DateAdd("d", 1, rtnDate)

Range("A" & i).Value = rtnDate

i = i + 1

Loop

End Sub

'After DateAdd("

'yyyy = Year
'q = Quarter
'm = Month
'y = Day of year
'd = Day
'w = Weekday
'ww = Week
'h = Hour
'n = Minute
's = Second
 
Back
Top