Macro to Autofill Dates between Start Date and End Date

lewis1

Board Regular
Joined
Jul 20, 2009
Messages
81
Hi, I have looked around the net, but I can't find a clear answer for the following.

I have a Start Date, eg: 08/23/2013 in Cell "D5", and
End Date; eg: 08/22/2018 in Cell "D7"

I would like a Macro which starts in Cell "D12" autofills column "D" with all the dates between and including the start and end date.

The name of the sheet I would like the macro to run on is named "Calendar"

Thanks!
Lewis.
 
heres half the solution...

Code:
Sub FillCal()
    Dim StartD As Date, EndD As Date
    
    StartD = Range("D5")
    EndD = Range("D7")
    
    For Row = 10 To EndD - StartD
        Cells(Row, 4) = StartD + Row - 1
        If Day(Cells(Row, 4)) > 14 And Day(Cells(Row, 4)) < 22 Then
            If Weekday(Cells(Row, 4)) = 4 Then Cells(Row, 5) = "3rd Wednesday"
        End If
    Next Row
    
End Sub
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
and heres part 2
Code:
Sub FillCal()
    Dim StartD As Date, EndD As Date
    
    StartD = Range("D5")
    EndD = Range("D7")
    
    For Row = 10 To EndD - StartD
        Cells(Row, 4) = StartD + Row - 1
        If Day(Cells(Row, 4)) > 14 And Day(Cells(Row, 4)) < 22 Then
            If Weekday(Cells(Row, 4)) = 4 Then Cells(Row, 5) = "3rd Wednesday"
        End If
        If Day(Cells(Row, 4)) = 1 Then
            If Weekday(Cells(Row, 4)) > 2 Then
                Cells(Row - 1, 6) = "Last weekday"
            ElseIf Weekday(Cells(Row, 4)) = 1 Then
                Cells(Row - 2, 6) = "Last weekday"
            ElseIf Weekday(Cells(Row, 4)) = 2 Then
                Cells(Row - 3, 6) = "Last weekday"
            End If
        End If
    Next Row
    
End Sub
 
Upvote 0
This is what I am starting with..

Actually with the below, I am only returning 11 results for

Start Date8/23/2013
Days 20.00
End Date 9/12/2013

<tbody>
</tbody>

Code:
Sub FillCal()
    Dim StartD As Date, EndD As Date
    
    StartD = Range("D5")
    EndD = Range("D7")
    
    For Row = 10 To EndD - StartD
        Cells(Row, 4) = StartD + Row - 1
    Next Row
    
End Sub

Hi Team, this does exactly what i'm trying to do but how do I make the code to populate only month end dates? I can seem to figure this out for the last three days :(
 
Upvote 0

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

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