Using Cell Contents Within a Formula

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
148
Office Version
  1. 2021
Platform
  1. Windows
I have been using the following formula which works fine, but I would like to be able to change the Year part of the dates and wondered whether there is a way of referencing a cell value which would contain the year and therefore make it easier to change, I was thinking about the Indirect function but I'm not sure how to use this or whether that would be the best way. I use 52 instances of this formula ( 1 for each week of the year ) and don't wish to have to frequently edit all of them.

=SUMPRODUCT((Records!$F$2:$F$40000>="2017-1-1"+0)*(Records!$F$2:$F$40000<"2017-1-7"+1)*((Records!$I$2:$I$40000>0)+(Records!$J$2:$J$40000>0)+(Records!$K$2:$K$40000>0)))

Thanks for any help.
 

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.
Not sure I completely understand your question, but if you are saying that you would like the year part here:
Code:
[COLOR=#333333]=SUMPRODUCT((Records!$F$2:$F$40000>="[/COLOR][COLOR=#ff0000]2017[/COLOR][COLOR=#333333]-1-1"+0)...[/COLOR]
to come from a cell, that should be easy enough to do.

Let's say that the year is in cell A1. Since you appear to be trying to change it to a date anyway, I would do it like this:
Code:
[COLOR=#333333]=SUMPRODUCT((Records!$F$2:$F$40000>=[/COLOR][COLOR=#ff0000]DATE(A1,1,1)[/COLOR][COLOR=#333333])[/COLOR][COLOR=#333333]...[/COLOR]
Note that the format of the DATE function is DATE(year,month,date)

Is that what you were looking for?
 
Upvote 0
Thanks for the reply.

Yes thats what I was after, I have edited the formula as below and that appears to work fine, I assume I have made the changes as required ?

=SUMPRODUCT((Records!$F$2:$F$40000>=DATE(R3,5,15))*(Records!$F$2:$F$40000<=DATE(R3,5,21))*((Records!$I$2:$I$40000>0)+(Records!$J$2:$J$40000>0)+(Records!$K$2:$K$40000>0)))
 
Upvote 0
You are welcome.
Glad I was able to help.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,467
Members
448,965
Latest member
grijken

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