Excel Indirect inside a sumproduct - excel

I'm pretty new with excel, but I have created a formula to calculate something from data I get from a sensor.
=100*((SUMPRODUCT(C16:C98,A16:A98)-SUMPRODUCT(C16:C98,A15:A97)+SUMPRODUCT(C15:C97,A16:A98)-SUMPRODUCT(C15:C97,A15:A97))/53.2)/((SUM(A16:A98)-SUM(A15:A97)))
as you can see it's quite long, and the values differ from time to time (sometimes it starts on c16 sometimes on c35,...)
I've tried adding an indirect link in the formula as the following:
original: SUMPRODUCT(C16:C98,A16:A98)
added indirect link: (SUMPRODUCT(INDIRECT(M25&":"&M26&","&M27&":"&M28)))
but this gives me a #REF! error.
Does anyone have an idea? Cheers.
B.
Edit: the M25 - M28 are the cells where I'll be putting my starting and ending cell number in. so in this case it would be "C16" in M25, "C98" in M26, "A16" in M27, "A98" in M28

You need to use INDIRECT for each array, try this:
=SUMPRODUCT(INDIRECT(M25&":"&M26),INDIRECT(M27&":"&M28))

Related

INDIRECT FORMULA

I am having trouble working out an error I am having with the formula below, I am a bit of a novice and its been more trial and error than anything so far but, I was hoping someone with a far greater knowledge could point out where I am going wrong.
The formula works fine without the indirect element I.e.
=SUMPRODUCT((PARROT!$o$12:$o$250<>"COMPLETE")*(PARROT!$n$12:$n$250<TODAY()))
but I want to replace the sheet name with an INDIRECT address as the name of the sheet could change
so the formula I came up with is but, it has an error:
=SUMPRODUCT(INDIRECT("'"&$A3&"'!$o$12:$o$250"),"<>"&"Complete")*(INDIRECT("'"&$A3&"'!$N$12:$N$250")<TODAY())
Help would be very much appreciated.
From your formula it seems you are just counting rows where O12:O250 is not equal Complete and N12:N250 is earlier than today. So, you can use COUNTIFS() formula with INDIRECT() easily. Try below.
=COUNTIFS(INDIRECT($A$3&"!$O$12:$O$250"),"<>Complete",INDIRECT($A$3&"!$N$12:$N$250"),"<"&TODAY())
If you need to sum values from a column then SUMIFS() will be your friend.

Inserting an INDIRECT into another formula to replace fixed values

I'm trying to do the following.
Take a value in a defined cell
Look up that value on another sheet called 'Updates'.
Look across the row for the last non-empty cell
Look up from there and return the header.
I know that if there was a defined range, the following formula works great for the last two steps.
=LOOKUP(2,1/(Updates!B3:E3<>0),Updates!B2:E2)
However I tried to make it more flexible with INDIRECT and came up with the abomination of a formula which I intended to just copy down.
=LOOKUP(2,1/INDIRECT("Updates!B"&B5+2&":S"&B5+2<>0),Updates!$B$2:$S$2)
However this just returns a #REF error. Is this type of thing not possible or is there a simpler way to go about it?
Thanks
I think you're not closing the INDIRECT statement before making the <>0 test - so move that bracket to the left and it should work; ie
= LOOKUP(2,1/INDIRECT("Updates!B"&B5+2&":S"&B5+2) <>0, Updates!$B$2:$S$2)

How to use ROW() in an Excel VLOOKUP formula?

I have two formulas for a cell reference: ="D"&ROW() and ="D$"&(ROW()-1)
These work fine on their own, but not when I put them in a VLOOKUP:
=VLOOKUP("D"&ROW(),D$3:"D$"&(ROW()-1),1,0)
Using the ADDRESS function gave the same error as using the ROW function. I have successfully worked around this using INDIRECT in the VLOOKUP formula, but that seems clunky and unnecessarily complicated. Is there a way to do this without using INDIRECT?
INDIRECT is Volatile; use INDEX instead:
=VLOOKUP(INDEX(D:D,ROW()),D$3:INDEX(D:D,ROW()-1),1,FALSE)
But upon typing that I see that it would be easier to just put the first row in the reference and keep it dynamic. So if the first row where 4 then
=VLOOKUP(D4,D$3:D3,1,FALSE)
Then as it is dragged/copied down only the D4 and the second D3 would change, leaving the first anchored on D3.

AVERAGEIF in Excel with irregular range

I know is a pretty basic question, but surprisingly, I can't seem to find a solution for it.
I'm looking to averageif every 10th cell that doesn't contain a 0 value, but for some reason the syntax doesn't work. I can't just take a range from between the first and last cell because there are other values in between that I don't want to be part of the average. I would have expected something like the below to work just fine, but it keeps returning an error message.
=AVERAGEIF(C4+C14+C24+C34+C44+C44,"<>0")
Any ideas? Thanks a bunch.
I've figured out a solution to my question (in case anyone comes across this in the future).
Instead of using AVERAGEIF, you can use a combination of the SUM and FREQUENCY functions.
To find the average of these cells [C4+C14+C24+C34+C44+C44] but exclude all 0 values, it looks like this:
=SUM(C4+C14+C24+C34+C44+54)/INDEX(FREQUENCY((C4+C14+C24+C34+C44+C54),0),2)
Credit to this blog for the help: http://colinlegg.wordpress.com/2013/05/04/conditional-average-on-non-contiguous-ranges-using-frequency/
I would use a "helper column"
In B1 enter:
=INDIRECT("C" & 4+10*(ROW()-1))
copy B1 to B2 thru B6
Then use:
=AVERAGEIF(B1:B6,"<>0")

Excel formula returns #value when named

I am working with the following table in Excel:
The following formula in evaluates normally when entered directly into a cell:
=DATE(YEAR(DATEVALUE($A$1)),MONTH(DATEVALUE($A$1)),DAY(INDIRECT(ADDRESS(2,COLUMN()))))
However, when I try to place put this in the named function test and call =test in another cell it returns a #VALUE! error. The best answer I have come up with after researching is that named formulas and the indirect function are not always compatible.
If anyone can shed some light to help explain what I am doing wrong or why I can not put an indirect call inside of a named range I would greatly appreciate it!
Yes, I don't believe INDIRECT will work with a named range - you shouldn't really need such a convoluted formula - try just
=(C$2&$A$1)+0
format as date
Edit: as per comments below, INDIRECT is OK but I don't think COLUMN() is liked in the named range. ROW and COLUMN functions sometimes behave badly because they return "arrays" even when single values, so you need another function like MAX or SUM to convert {2} to 2, e.g.
=DATE(YEAR(DATEVALUE($A$1)),MONTH(DATEVALUE($A$1)),DAY(INDIRECT(ADDRESS(2,MAX(COLUMN())))))
although I think there are shorter methods as I indicated above....

Resources