Filling dates from start Date to End date

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys,

I am not able to get this simple code running..

Code:
Sub FillDates()
    Dim datStart As Date
    Dim datEnd As Date
    Dim row As Long
    
    datStart = Range("E1").value
    datEnd = Range("E2").value
    
    For row = 5 To datEnd - datStart
'        Cells(row, 2) = datStart + row - 1
'        Cells(row, 2) = datStart - 1
'        Cells(row, 2) = datStart + 1
        Cells(row, 2) = datStart + 1
        
    Next row
End Sub

all those things I tried but no luck to get the dates filled from "B5") for the first date down to the last date.

As I am sure it is simple but I can not get it to run correctly.

Maybe someone can help.

Thanks
 
Thanks guys,
for your input and different approaches for the code ..
I would of been happy to be able to worked one out of myself gg .-)
You're welcome. Glad to add to the options. :)
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,215,047
Messages
6,122,858
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top