ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   date list (https://www.excelbanter.com/excel-programming/273154-re-date-list.html)

Tom Ogilvy

date list
 
Sub fill1()
Dim dt1 As Date
Dim dt2 As Date
dt1 = DateValue("08/02/2003")
dt2 = DateValue("08/13/2003")

Range("A1").Value = dt1
Range("A1").NumberFormat = "dd/mm/yy"
i = 0
Do While dt1 + i < dt2
i = i + 1
Range("A1").Offset(i, 0).Value = dt1 + i
Range("A1").Offset(i, 0).NumberFormat = "dd/mm/yy"
Loop

End Sub


you could also do it in one step using fill.

Sub FillDates()
Dim dt1 As Date
Dim dt2 As Date
dt1 = DateValue("08/02/2003")
dt2 = DateValue("08/13/2003")
Selection(1).Select
ActiveCell.Value = dt1
ActiveCell.DataSeries Rowcol:=xlColumns, _
Type:=xlChronological, _
Date:=xlDay, _
Step:=1, _
Stop:=dt2, _
Trend:=False
End Sub


--
Regards,
Tom Ogilvy

libby q:-) wrote in message
...
Hi all

Given a start date eg 02/08/03 and an end date eg 13/08/03
is there any way of getting excel to list the dates
inbetween?

Many thanks in advance.





All times are GMT +1. The time now is 04:29 PM.

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