• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to list all dates between two dates

Belleke

Well-Known Member
Hi everybody,
I have a userform with a textbox Start Date,End Date & # of days.
I looking for the code that gives me the result as shown in the table when I press the
button.
UF.jpg Result.jpg
 
Belleke
Without Your sample file,
Your would get an idea from next to samples:
Code:
Sub Do_It()
'   get Your start_date, end_date, days as needed
    For d = start_date To end_date
        Cells(d - start_date + 2, 2) = d
    Next d
' OR
    For d = 0 To days
        Cells(2 + d, 2) = start_date + d
    Next d
End Sub
 
Hi Vletm,
Thanks for helping me.
See example.
 

Attachments

  • Chandoo example.xlsb
    111.1 KB · Views: 10
Belleke
You didn't test my samples.. hmm?
Your file has 'something' which won't work with my Excel,
but here one sample version as You've written.
Ps. You would add line On Error Resume Next in then beginning of that Sub.
 

Attachments

  • Chandoo example.xlsb
    87.6 KB · Views: 16
Hi,
I was to fast with my answer, a new entry should add at the bottom instead of overwrite.

Never mind, I found the solution with find.
 
Last edited:
Back
Top