ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do Until Loop (https://www.excelbanter.com/excel-programming/427619-do-until-loop.html)

sgl

Do Until Loop
 
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




AltaEgo

Do Until Loop
 
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

--
Steve

"sgl" wrote in message
...
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




sgl

Do Until Loop
 
Thank you for assistance that worked for me

"AltaEgo" wrote:

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

--
Steve

"sgl" wrote in message
...
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






All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com