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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Do Until Loop 6
'Do Until...' Restart 5
Do Until Loop 1
Do Until empty loop 2
VBA Loop until certain cell! 9
simple nested loop question 8
Repeat a marco with number of times or loop until End 6
Do Until Loop 2

Back
Top