Macro that shows range of dates

1

1234

Hi, hope you can help me with this:

I have in A1 start date with format yy/mm/dd hh:mm and in A2 an end
date with the same format. I want a macro that puts in column D all
dates between the range of the strat date and the end date.


Thank you so much
 
1

1234

Hi,

Thanks for your help. There´s no source. I introduce a date on cell A1
which is start date and a date on cell A2 which is End Date. I select
whatever date I want, there´s no source. I want a macro that puts all
the dates between A1 and A2 in column D. Example:

A1 12/01/2009
A2 12/05/2009

Column D must show

D1 12/02/2009
D2 12/03/2009
D3 12/04/2009

Thanks
 
R

Rick Rothstein

This macro should do what you want (don't forget to format your cells the
way you want them beforehand)...

Sub FillDatesIn()
Dim D As Date, X As Long
For D = Range("A1").Value + 1 To Range("A2").Value - 1
Range("D1").Offset(X).Value = D
X = X + 1
Next
End Sub

--
Rick (MVP - Excel)


Hi,

Thanks for your help. There´s no source. I introduce a date on cell A1
which is start date and a date on cell A2 which is End Date. I select
whatever date I want, there´s no source. I want a macro that puts all
the dates between A1 and A2 in column D. Example:

A1 12/01/2009
A2 12/05/2009

Column D must show

D1 12/02/2009
D2 12/03/2009
D3 12/04/2009

Thanks
 
1

1234

Hi,

Thank you so much for your answer. When I run the macro it says that
the expression is too complex. How can I fix this?

Best regards,
 
D

Don Guillett

Option Explicit
Sub makedates()
Dim i As Long
For i = 1 To Range("b1") - Range("a1") + 1
Cells(i, "d") = Range("a1") - 1 + i
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Hi,

Thanks for your help. There´s no source. I introduce a date on cell A1
which is start date and a date on cell A2 which is End Date. I select
whatever date I want, there´s no source. I want a macro that puts all
the dates between A1 and A2 in column D. Example:

A1 12/01/2009
A2 12/05/2009

Column D must show

D1 12/02/2009
D2 12/03/2009
D3 12/04/2009

Thanks
 
R

Rick Rothstein

When I run the macro on simple test data, it runs fines. What version of
Excel are you running and which line of code is the debugger stopping on
(highlighting) when the error message is generated?

If you are using XL2003 or XL2004, then you can send the workbook to me so
that I can see the problem happen directly and, perhaps, see what is causing
it. If you choose to send it to me, remember to remove the NO.SPAM stuff
from my email address.
 

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

Top