Autofilling of Dates between Date Ranges

Jameo

Active Member
Joined
Apr 14, 2011
Messages
270
Hi all,

I basically have two seperate sheets. One with guarenteed pressures, and one with actual pressures.

I am looking to write a macro that will allow a user to select a start date and an end date, and then the results will be combined on another sheet.

The most simple way to combine this data in my opinion would be using a vlookup, however my problem comes with the formatting of the combined sheet.

Is there any way that I can get excel, through VBA, to auto fill the dates between the two selected date ranges?

Thanks in advance
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hmm maybe something such as this?

Code:
Dim i As Long, j As Long
j = 1
With ActiveWorkbook
   For i = 0 To DateDiff("d", .Sheets(1).Range("a2"), .Sheets(1).Range("B2")) - 1
       If Format(DateAdd("d", i, .Sheets(1).Range("a2")), "ddd") = "Fri" Then
           .Sheets(2).Range("A1").Offset(j, 0).Value = Format(DateAdd("d", i, .Sheets(1).Range("A2")), "dddd, d MMMM yyyy")
           j = j + 1
       End If
   Next i
End With

Although I will have to modify is slightly as this is only used to populate fridays
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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