I am trying to nest the VLOOKUP function as shown below
=VLOOKUP(D21, VLOOKUP(B21, PCLIST, 3, FALSE), 2, FALSE)
The nested VLOOKUP is accessing PCLIST which is a list of names of named spaces that coordinate with B21.
By itself this expression evaluates as expected.
The outside VLOOKUP function will evaluate fine if I specifically name the named space I want to look.
It seems like there is an error somewhere when evaluating the nested VLOOKUP as a named range.
I am receiving the #VALUE! error
You are on the right track. Your inner vlookup() is returning the name of a named range which is what you are trying to search with your outer vlookup().
The problem is that the outer vlookup() is seeing the return from the inner vlookup() as a string, and so it's erroring out. To turn a string into a range in Excel we use the Indirect() formula:
=VLOOKUP(D21, Indirect(VLOOKUP(B21, PCLIST, 3, FALSE)), 2, FALSE)
Related
I have a interesting puzzle going on which I believe is a syntax issue that has to do with the nesting of the formula in question. The reason I'm using such a funky formula is probably longwinded to the point of not being interesting, and certainly not useful to solving the issue I'm having. It would be possible to solve my issue without this formula but it would require a VBA project which isn't ideal for this use case. The formula is as follows:
=SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE)))
Pulling the full formula apart, I have two formulas that work as expected:
Piece One: =SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,'Sheet1!'$AV:$AV)
Piece Two: =CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE))
Piece Two returns a value of 'Sheet1'!AV:AV and Piece One returns a value of 1,000,000 which is the correct SUMIF for the criteria I've set up in the formula. I've tried all sorts of combinations of ( and ) but continue to have Excel give me the message of either Your formula is missing a open or close parenthesis or Did you mean for this to be a formula? When starting a cell with a = or -.....
I'm trying to get the nested formula to resolve the "Part Two" first, so that when the entire nested formula evaluates it would solve "Part Two" which would leave me with an identical formula to "Part One" which would result in the 1,000,000 answer.
What am I missing here? Thanks in advance - this one's got me stumped!
Excel will not by default interpret your string as a range reference. You need to pass it to INDIRECT so as to be interpreted as such:
=SUMIF(
Sheet1!$BR:$BR,
Sheet2!$C19,
INDIRECT(
CONCAT("'Sheet1'!", VLOOKUP(CONCAT($B$1, " ", F$5), Sheet3!$J:$P, 7, FALSE))
)
)
Piece Two returns a value of 'Sheet1'!$AV:$AV
Piece Two in this case returns a string value, that happens to say 'Sheet1'!$AV:$AV. What you need piece two to return is not a text string, but a reference (or 'link') to the range on the sheet that is called 'Sheet1'!$AV:$AV.
To convert a string to a range reference you use the INDIRECT() function.
So your new formula is
SUMIF('Sheet1'!$BR:$BR,'Sheet2'!$C19,INDIRECT(CONCAT("'Sheet1'!",VLOOKUP(CONCAT($B$1," ",F$5),'Sheet3'!$J:$P,7,FALSE))))
=ADDRESS(3,1) 'evaluates to $A$3
=ROW($A$3) 'evaluates to 3
Why can't I nest them?
=ROW(ADDRESS(3,1)) 'Gives an error.
Try:
=ROW(INDIRECT(ADDRESS(3,1)))
instead of using ADDRESS which returns a string, consider using INDEX which will return a cell reference. The general format of INDEX is:
INDEX(Range you want to look in, rows down from top row, columns right for first column)
so in order to reference your whole sheet like address would you would need to select the range of the entire sheet:
=INDEX($A$1:$XFD$1048576,3,1)
The above formula actually returns the cell reference of $A$3 ($ is due to 3 and 1 being hard coded) then turns around and displays the contents of $A$3. As a result you don't actually see the $A$3. On the interesting side of things it also means you can define a range with INDEX(...):INDEX(...). To finish off your formula you would nest the INDEX in your ROW function as follows:
=ROW(INDEX($A$1:$XFD$1048576,3,1))
This avoids the use of the volatile function of INDIRECT and some of its other restrictions.
I have a question about excel function.
The question is:
I want to use VLOOKUP-like function, but VLOOKUP only search leftmost row.
Is there any function that searches non-leftmost row (you can select) and the behavior is almost same as VLOOKUP function?
If you don't understand, please see this picture.
I want to do like this in Excel.
Thank you for reading.
INDEX MATCH Combo
You can use combination of 2 functions:
INDEX function
The INDEX function returns a value or the reference to a value from within a table or range.
MATCH function
The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in the range. For example, if the range A1:A3 contains the values 5, 25, and 38, then the formula =MATCH(25,A1:A3,0) returns the number 2, because 25 is the second item in the range.
Example
=INDEX(Name_col, MATCH(Rank_input, Rank_col, 0)).
Equivalent, using your concrete data, assuming you have "Alex" in A3:
=INDEX($A$3:$A$7, MATCH(A10, $C$3:$C$7, 0))
On C123 =COUNTIFS(Data!A:A,A123,Data!E:E,Data!G:G,B123,Data!Q:Q,"mobilepod")
its giving me Error, I know I'm missing criteria2 but isn't that an optional?
I have also tried
=COUNTIFS(Data!A:A,A123,Data!E:E,"",Data!G:G,B123,Data!Q:Q,"mobilepod")
No Errors no result
Data Sheet
To use an OR logic in one of the criteria for your COUNTIFS function, put the multiple ctrieria values in as an array of constants and wrap the whole thing in a SUM function.
=SUM(COUNTIFS(data!A:A, A123, data!E:E, {"DIST","DIST 2"}, data!G:G, B123, data!Q:Q, "mobilepod"))
I have some named ranges some are single cell NamedRanges others are multicelled.
When I use "=AnyNameofSingleCellNamedRange" in any cell of the workbook.It returns it's value.
But When I use "=AnyNameofMultiCellNamedRange" It returns #VALUE error saying it's of the wrong data type.
If you enter =MultiCellNamedRange into a cell on the same row as the range it refers to Excel does an implicit intersection and gives you the value that is the intersection of the named range and the row. if there is no intersection then you get #Value.
If you enter =MultiCellNamedRange as a multicell array formula using Control-shift-Enter then Excel does not do implicit intersection and will return an array of values from the multicell named range.
Simplest method of accessing data from a multi-celled named range is the INDEX function. For example:
=INDEX(AnyNameofMultiCellNamedRange,2)
This gives the 2nd value of a multi-celled named range.
=INDEX(AnyNameofMultiCellNamedRange,2, 3)
In a 2D array, this shows value of the cell on the 2nd row and 3rd column.
In VBA, it is even simpler - you reference it as you would any other array. For example:
x = AnyNameofMultiCellNamedRange (2,3)
Note that without the (x,y) or (x) reference in brackets after the named range, you're essentially saying "make x = to the entire array".
=AnyNameofMultiCellNamedRange is actually returning an array of values. Depending on the physical location of the formula, you may see one of the values, or the #VALUE! error.
To see the individual values, you can either enter it as an array formula over a range of the same dimensions, or you can use the Index function to see individual values. It will work as required in functions that take array arguments.