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.
Related
It's probably a simple problem, but I did not even know the keywords to google it ;/. Let's say I have this data :
Now I also have this litle formula:
If I know drag the C cell to the right, Excel will attempt the following caluclation:
=2+B1
What I want him to do is to attempt this calculation
=2+A2
Of course the easiest solution would be to store my initial data in one row instead of 1 column, but it is really inconvenient for me. Thanks for any help
You can use the indirect() method to reference a cell by it's "String identifier", i.e. "A3". When filling out to the right, use CONCATENATE() and COLUMN() to create your String identifiers {A1,A2,A3,A4,A5...} as required:
=2+INDIRECT(CONCATENATE("A";COLUMN()-2))
This will result in the following:
Side-Node: If you want this for some x/y-Grid-Generation, you can also be lazy,
and just insert =COLUMN() for every cell from "A1 - Z1" and ROW() for every cell from "A2 - A24".
(Or even avoid these at all and directly perform your actual calculation by using column() and row() as replacement for your x/y.
You may try using a combination of the INDIRECT and COLUMN functions:
=2+INDIRECT("A"&(COLUMN()-2))
You would paste the above formula into cell C1, and then drag across to the right however many columns/rows you wanted to cover.
This would result in the following:
This works because COLUMN()-2 returns 1 for the C column, 2 for the D column, and so on. Therefore, the formula will be calling INDIRECT on A1, A2, etc. for column C, D, and so on.
In general, if you want relative references to move down as cells are dragged to the right, you can use this:
Instead of:
= 2+A1
Do:
= 2+INDEX($A:$A,COLUMN()+<offset>)
Where <offset> is whatever offset you need. The offset will change depending on which column the starting formula is located in.
INDEX should be preferred over INDIRECT because INDIRECT is volatile (must recalculate after any change to the workbook) but INDEX is not (only recalculated when one of the inputs the formula, in this case $A:$A, changes).
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)
I have a question regarding COUNTIFS. The simple boiled down version of what I am trying to do is this:
I am trying to use COUNTIFS to count the number of entries that the cell in a column is either blank or in the future (greater than today) and that is marked with an “X” in another column.
There are several other renditions in the formula but if I can get this, I can get the rest. So far, I have this:
=SUM(COUNTIFS($C$2:$C$50,{"";">"&TODAY()},$E$2:$E$50,"X"))
Excel won’t let me return out of the formula and highlights the quotation mark following the greater than symbol.
=SUM(COUNTIFS($C$2:$C$50,{"";">100"},$E$2:$E$50,"X")) works fine when I play around and test things but when I try to add in &TODAY() or reference a cell, things go sideways.
Any suggestions as to what I am doing wrong? The actual formula is quite long and there are several comparisons that are made between columns. I've seen some references to using SUMPRODUCT but haven't been able to figure it out that way either.
You can use a formula to generate the criteria array, i.e.
=SUMPRODUCT(COUNTIFS($C$2:$C$50,IF({1;0},"",">"&TODAY()),$E$2:$E$50,"X"))
I used SUMPRODUCT in this version because with SUM you'd need CTRL+SHIFT+ENTER
The IF function generates an array that resolves to something like this:
{"";">43060"}
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))
This is the formula that I am currently using:
=SUMPRODUCT((INDIRECT("A2"):INDIRECT("A"&(ROW()-1))=A359)*1)
It works great, but I would like to use this instead:
=SUMPRODUCT((INDIRECT("A2"):INDIRECT("A"&(ROW()-1))=INDIRECT("A"&(ROW())))*1)
Unfortunately I get a #VALUE!. What am I doing wrong? Both INDIRECT("A"&ROW(())) and A359 return the same value, so I'm not sure why this won't work.
The reason I am not using a simple COUNTIF function is because I stripped my formula of all unnecessary components and only left the part that I am having trouble with (i.e. I need to use the SUMPRODUCT formula and a COUNTIF formula will not work)
Thanks in advance!
I'm not sure why you need INDIRECT instead of ordinary cell references but the specific problem here is that ROW function returns an "array", even when it returns a single value, e.g. it returns {"x"} rather than just "x" - and in some circumstances Excel can't process that.
Try wrapping the second ROW function in a SUM function - the value doesn't change but it gets rid of the array, i.e.
=SUMPRODUCT((INDIRECT("A2"):INDIRECT("A"&(ROW()-1))=INDIRECT("A"&SUM(ROW())))*1)
This will eliminate #VALUE! eror while leaving the essential structure of your formula unchanged
Try this one:
=SUMPRODUCT((($A$2:INDEX($A:$A,ROW()-1))=INDEX($A:$A,ROW()))*1)
it gives you the same result.
But above formula is volatile. Instead I would use next one, say in B3 :
=SUMPRODUCT((($A$2:$A2)=$A3)*1)