PDA

View Full Version : Generate list of dates



enfantter
01-30-2008, 01:08 AM
Hey all,

I'm trying to generate a list of dates. All dates between two dates should be displayed. The two dates are entered in a userform.
The code from the userform looks like this:

Private Sub upfbtn_Click()
Dim start As Date
Dim slut As Date

slut = sluttxt.Value
start = starttxt.Value
diff = Val(slut) - Val(start)
With Worksheets("Data")
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To diff + 1
.Cells(lastrow + i, "A").Value = "Jack"
.Cells(lastrow + i, "B").Value = start + i - 1
Next i
End With

indferie.Hide

End Sub

But it doesnt work - any sugs?!

Bob Phillips
01-30-2008, 01:34 AM
Although I might be a bit more explicit with the date casting if I had written it, it works fine for me. What problems are you getting?

enfantter
01-30-2008, 02:08 AM
well, if i try to generate dates btwn 04/04/2008 and 28/03/2008 it doesnt work ..

Aussiebear
01-30-2008, 02:14 AM
Could it be that you are looking for dates in reverse order?

enfantter
01-30-2008, 02:48 AM
maybe...
Im trying to generate a number of dates corresponding to the difference btwn the end date (slut) and the start date (start)..

Bob Phillips
01-30-2008, 03:03 AM
Doesn't work is a statement that adds nothing to what you said before.