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)
Related
I am trying to use a variable range based on a pre-defined criteria. In my case I would like to find the range of the “AUD” cells in the table. I managed to get the beginning of the range thanks to:
=ADDRESS(1;MATCH("AUD";1:1;0))
And then I found the end of the range using a slightly modified above formula:
=ADDRESS(1;(MATCH("AUD";1:1;0)+(COUNTIF(1:1;"AUD"))-1))
Then I simply combined the results with the following formula:
=(B4&":"&C4)
And the achieved result was:
$B$1:$D$1
However, I am having difficulties implementing this result inside formulas in which range must be defined, which brings me to my following questions:
Is such kind of implementation possible in EXCEL, I suspect that the result is considered as a simple text and not actually a cell reference? Is there a way I can change that?
One step further, if we trim (for example from $B$1 to just $B) can we still make the formula working?
Due to the fact that to save space I will probably write all the above formulas inside one formula and I expect this formula to become huge, would it be possible to create a VBA public function which can store the range in a variable and then just refer this variable to the formula - for example, SUMIF("=audRefCell()";"AUD";2:2).
I would like to thank you in advance for the help!
I have a table of fruits in Excel 2013.
I'd like to fill the "Category" column by searching from the current row to the top until the first occurrence of "::", which is the keyword for a category in the table.
If there was some way to reverse a range, I could do something like "=Match("::*"; $A6:$A$2)" to find the row. However, this is not possible.
Does anyone know how this might be accomplished using formulas?
Using your provided sample data, and assuming your data is already organized as shown in your sample, you can take advantage of that organization and use this formula in cell C2 and copy down:
=IF(LEFT(A2,2)="::","",IF(LEFT(A1,2)="::",MID(A1,4,LEN(A1)),C1))
Assuming your table is in A1, put this in C3:
=INDEX(A:A, AGGREGATE (14,6,ROW($A$1:A2)/(LEFT($A$1:A2,2)="::"),1))
And copy down.
Here's a kinda different approach. I'm just basically responding to this part of your post to prove this is possible:
If there was some way to reverse a range, I could do something like "=Match("::*"; $A6:$A$2)" to find the row. However, this is not possible.
Reversing a range is possible, it's just tricky.
As you pointed out: $A6:$A$2 won't work since this is equivalent to $A$2:$A6.
However, without getting into the nitty-gritty details, this array formula will reverse this range:
= INDEX($A$2:$A6,N(IF({1},MAX(ROW($A$2:$A6))-ROW($A$2:$A6)+1)))
Note this is an array formula, so you must press Ctrl+Shift+Enter instead of just Enter after typing this formula into a cell.
You could use this in combination with your MATCH formula to get the desired result (which tells you how many rows up the :: row is):
= MATCH("::*",INDEX($A$2:$A6,N(IF({1},MAX(ROW($A$2:$A6))-ROW($A$2:$A6)+1))),0)
(Also haha this is kinda cool: Usually you see MATCH used within INDEX to effectively get a VLOOKUP type of functionality. This is the first time I have ever seen it the opposite way of having INDEX within MATCH.)
Note that I'm not saying this is necessarily the best approach for this specific problem, just proving a point that arrays can be reversed.
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.
In my current sheet I have some numbers in a column, which represent the row which I want to get the data from in another sheet. And I want to get it from the same column in which I am using the function...
I know using =Sheet1!A1 for instance gets me what is in A1 on Sheet1
and
=CONCATENATE("A",A1) being on sheet two, brings me back A + whatever value is stored in A1 on sheet number two... for simplicity let's say it's a one... so it would return A1
I am on Sheet2
I'm trying
=Sheet1!CONCATENATE("A", A1)
but the formula contains an error, I've tried rewriting this in many ways but it never works... any idea what the correct syntax I need is?
Greatly appreciated!
THanks
As Magicianeer said, you have to use the INDIRECT function. For your example:
=INDIRECT(CONCATENATE("Sheet1!","A",A1))
Should give the results you need.
However, it's a bit lengthy, and you can use & instead of CONCATENATE, and you can directly use Sheet1!A:
=INDIRECT("Sheet1!A"&A1)
What is evaluated in the brackets is Sheet1!A1, and INDIRECT converts this from text to a reference.
Try:
=CONCATENATE("A", Sheet1!A1)
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....