Date Range

ak255

New Member
Joined
Aug 6, 2007
Messages
5
Hello,
I need to find out a way to make a date range out of a starting date and an ending date
i.e.

a1 6/25/2007
a2 7/4/2007

what i want then is for collumn b to have all the date inbetween those two dates written out

b1 6/25/2007
b2 6/26/2007
b3 6/27/2007 etc.

I am using this formula in a macro, so each date range is going to be different in size, so I need a formula that is flexible for all date ranges

Thanks!
 
two small changes
Code:
Sub PlaceDates()
Dim DateCount As Long, StartDate As Long, EndDate As Long, FormulaString As String
StartDate = Int(Range("A1").value)
EndDate = Int(Range("A2").value)
FormulaString = Range("C2").FormulaR1C1
For DateCount = StartDate + 1 To EndDate
    Range("B:B")(DateCount - StartDate + 1) = DateCount
    Range("C:C")(DateCount - StartDate + 1).FormulaR1C1 = FormulaString
Next DateCount
Columns("B:B").NumberFormat = "m/d/yyyy"
End Sub
Changed C1 to C2 and added a "+1" after start date in the for loop. This will not effect B1 or C1, so you will probably want to change B1 to =A1.

HTH,
~Gold Fish
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,216,499
Messages
6,131,010
Members
449,613
Latest member
MedDash99

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