Add cell value to formula

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
473
Office Version
  1. 2007
Platform
  1. Windows
Hello,
I posted a similar question a while ago and have most of it working. However, I have one other related question if you please.

I have a formula that I would like to add a cell address to in the range. Here is a simplified version of the formula:
Rich (BB code):
=SUMPRODUCT(--(YEAR($C$32:$C$365)=R39),$Q$32:$Q$365)

What I’d like to do is replace the 365 with the value in cell T13. Maybe this is not even possible but I thought it would look something like this (apparently I am wrong):
Rich (BB code):
=SUMPRODUCT(--(YEAR(“$C$32:$C$” & Range(“T13”).value)=R39),”$Q$32:$Q$” & Range(“T13”).value)

Thanks for viewing,
Steve
 
There might be other ways but this is the first that comes to mind:

Excel Formula:
=SUMPRODUCT(--(YEAR($C$32:INDEX($C:$C,T13))=R39),$Q$32:INDEX($Q:$Q,T13))
 
Upvote 0
Thank you Jeff for your quick response. This appears to be doing what I want. I had to modify the code slightly. I added $T$13 to hold the cell and added the remainder of the function. Here‘s my final:
Rich (BB code):
=IF(SUMPRODUCT(--(YEAR($C$32 : INDEX($C:$C,$T$13))=R39),$Q$32 : INDEX($Q:$Q,$T$13))>0,SUMPRODUCT(--(YEAR($C$32 : INDEX($C:$C,$T$13))=R39),$Q$32 : INDEX($Q:$Q,$T$13)),"")

I have some more testing to do but this looks really promising.

Again, much appreciated,
Steve
 
Upvote 0
The key thing that makes this work is that INDEX returns a cell reference, not a value. This is transparent because if you use a cell reference where Excel expects a value, it will use the value for that reference. But here I'm using it where Excel expects a cell reference. So you can use it as part of a range.

Your initial idea could have worked if you had used INDIRECT, but my version is simpler, non-volatile, and easier to copy/paste to any location.
 
Upvote 0

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