Macro to put a value into each date in a sheet

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I've built a sheet that has a cell for each day and a list of tasks
I want to fill my sheet with these tasks

So "AA16:ADP16" contains Dates one day after the other like a calendar list
Column P = Start Dates
Column Q = End Dates
Column O = Data to copy.

So what I want is a macro that will fill in the dates with Column O's data
So Row 17 to last row

Find startdate and end date and fill into row 17 of that column the amounts

Below is an example of what I mean
OPQAAABACADAEAFAGAHAI
DataStart DateEnd DateDate01/11/1902/11/1903/11/1904/11/1905/11/1906/11/1907/11/1908/11/19
1002/11/1907/11/19101010101010
2005/11/1905/11/1920
3001/11/1902/11/193030
4004/11/1907/11/1940404040
so the amounts above are the amounts I want the macro to fill in for me.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Why not just use a formula?

Book1
OPQAAABACADAEAFAGAH
1DataStart DateEnd Date01/11/201902/11/201903/11/201904/11/201905/11/201906/11/201907/11/201908/11/2019
21002/11/201907/11/2019 101010101010 
32005/11/201905/11/2019    20   
43001/11/201902/11/20193030      
54004/11/201907/11/2019   40404040 
Database
Cell Formulas
RangeFormula
AA2:AH5AA2=IF(AND(AA$1>=$P2,AA$1<=$Q2),$O2,"")
 
Upvote 0
Hi fluff,
Because I'm going to end up with about 50 of these and the formulas make the document huge
 
Upvote 0
In that case how about
VBA Code:
Sub tonywatson()
    With Range("AA2:ADP5")
        .Formula = "=IF(AND(AA$1>=$P2,AA$1<=$Q2),$O2,"""")"
        .Value = .Value
    End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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