Excel - using defined name in a SUMPRODUCT - excel-formula

I am trying to evaluate a simple SUMPRODUCT between 2 rows. But one of the row contains an array of Defined Names (each one being linked to a single numeric value).
I have used the INDIRECT function to recall the numbers related to the Defined Names but I understand that INDIRECT is not managing well this array and thus the SUMPRODUCT return an error.
=SUMPRODUCT (A1:C1 , INDIRECT (A2:C2))
where A2:C2 contains respectively {EUR,GBP,USD} names defined as exchange rate of the day (single numeric value in name manager)

The INDIRECT function takes as an argument a reference, or a named range defined as a reference; not a range of names (named ranges).
I believe you have 2 alternatives though:
1) Give the INDIRECT the real reference to your values (as a range), or
2) Create one named range to reference all your values and give it as an argument to the INDIRECT.
HTH,
Matan

Related

VLOOKUP results in #N/A with Exact Match

Using Microsoft 365 Excel.
In cell K2, I have:
=VLOOKUP(F2,METERS,2,FALSE)
In cell L2:
=VLOOKUP(G2,KNOTS,2,FALSE)
The result in L2 is what I expect.
No matter what I do to the equation or anywhere in the workbook, I keep getting #N/A in K2.
When I replace the named range in K2, METERS for KNOTS, the function evaluates properly.
Copying the named range works properly, so there's nothing wrong with the named range:
=METERS
returns the complete named range without errors.
Checking the value in F2 evaluates as TRUE, so the value is an exact match:
=(F2=MS!A210)
Oddly enough, if I change the function in K2:
=VLOOKUP(F2,METERS,2,TRUE)
then it sort of works, in that it gives me a value instead of #N/A, but doesn't give me exactly the result I need.
I tried moving the function from K2 to different cell and using a different cell for the lookup value; then no matter what I input, I get 0.
I know the syntax in K2 is correct. The named range is correct. Everything seems to be correct.
Yet no matter what, I get #N/A.
Here/screenshot(s) refer:
Given the info you have provided, the only reasons I can think of why this could occur are:
a) Conflicting named ranges with common names/different scopes
b) Inconsistency between the two named ranges you're using
These aren't mutually exclusive (a different scope could lead to an inconsistency). I'll demonstrate the following in this solution:
No issues arise when using two different names that refer to the exact same range / sheet / scope
How easily issues can arise due to duality of scope (e.g. worksheet vs. workbook) for common names, and how either of these can be referenced anywhere in the workbook
Finally, I'll comment on the 'true/false' indicator in the vlookup function you mentioned, and propose an alternative / improved feature avail. with Office 365.
Context
Conflicts RE: named ranges can arise in several ways - e.g. when multiple sheets contain named ranges that have common names, when copying a function that comprises a named range from one sheet to another, etc. It's possible to produce a conflict from one workbook to another in this fashion too.
When copying such a function from one sheet to another you should see the something like the following UI appear:
Sheet 1 - correct referencing
Comprises two named ranges (range_1, range_2 resp.) which both refer to the exact same range (with identical scopes). Vlookups operate perfectly fine and produce identical results:
Besides their name, range_1 and range_2 are otherwise identical in every way per the following in Name Manager:
Sheet 2 - conflict / error
Copy of Sheet 1, with range_1 amended to only include the 1st column - the same vlookup functions as Sheet 1 now produce an error for range_1:
Note: copying the functions from Sheet 1 have now produced the following in Name Manager:
However, I'm still able to reference range_1 from Sheet 1 per the following tooltip that appears when I start typing '=range_1' in any cell within Sheet 2:
Thus its possible to retrieve what appears to be the 'correct' range for range_1 in any cell in the workbook by referencing the original scope (workbook), despite the vlookup in Sheet 2 producing an error.
It this is not the case (and you do not have 'duality' in scopes for the same named range) then the only other reason I can think of is inconsistency RE: formulation. If they are truly identical in the ranges they reference, then I would suggest adopting a single name (KNOTS, given this appears to function correctly) to simplify the workbook/functions and improve auditability.
Vlookup parameter (0/1)
RE: vookup(range, lookup, True/False) -
True (i.e. '1') parameter will return an 'approximate' match (which distinguishes this function from alternatives such as index/match). However, xlookup is advisable / preferred over vlookup in any case given it also has this feature and can reference to the left or right of the lookup column (vlookup works strictly to the right). Although it is more complex with additional parameters/arguments to consider. See here for details.

excel: Look up value within cell from list of values in other range [duplicate]

Currently I have a set of cells, and each has, among useless information, a unique identifier. I also have a list of these unique identifiers, as well as what value each identifier corresponds to.
What I would like to do is find which, if any, identifier a cell contains, and then output the corresponding value, below is an example:
http://i.stack.imgur.com/97aKI.png
So where the cell contains "ADC", I would like excel to find where ADC comes up in the reference array, and then return the corresponding value.
If this can be done with a formula or a macro, either would be great. I have tried fiddling with index, match, and search, in various combinations, but nothing seems to be working. I have found creating a massive if statement to be impractical as there are about 70 unique values to search for.
Any suggestions would be welcome!
edit: I was recommended to use vlookup, but I am not looking for an identical match, but instead for a specific value contained within a string. If vlookup does have this functionality then could somebody show me how to put this into practice with my specific example?
One method of a 'reverse-wildcard' lookup can be achieved is with the newer AGGREGATE¹ function. This function can produce cyclic calculation and has an option (e.g. 6) to discard errors. Use this to produce a row number on the match to the cross-reference table with the INDEX function returning the actual value.
      
The formula in B3 is,
=INDEX(F$3:F$5, AGGREGATE(15, 6, ROW($1:$3)*SIGN(MATCH("*"&E$3:E$5&"*", A3, 0)), 1))
Note that ROW(1:3) is the position within F3:F5, not the actual row number on the worksheet. I've also scrambled the Find and Insert values in your original cross-reference table to avoid the perception of an associative lookup match.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

Index Match with WildCards - Excel [duplicate]

Currently I have a set of cells, and each has, among useless information, a unique identifier. I also have a list of these unique identifiers, as well as what value each identifier corresponds to.
What I would like to do is find which, if any, identifier a cell contains, and then output the corresponding value, below is an example:
http://i.stack.imgur.com/97aKI.png
So where the cell contains "ADC", I would like excel to find where ADC comes up in the reference array, and then return the corresponding value.
If this can be done with a formula or a macro, either would be great. I have tried fiddling with index, match, and search, in various combinations, but nothing seems to be working. I have found creating a massive if statement to be impractical as there are about 70 unique values to search for.
Any suggestions would be welcome!
edit: I was recommended to use vlookup, but I am not looking for an identical match, but instead for a specific value contained within a string. If vlookup does have this functionality then could somebody show me how to put this into practice with my specific example?
One method of a 'reverse-wildcard' lookup can be achieved is with the newer AGGREGATE¹ function. This function can produce cyclic calculation and has an option (e.g. 6) to discard errors. Use this to produce a row number on the match to the cross-reference table with the INDEX function returning the actual value.
      
The formula in B3 is,
=INDEX(F$3:F$5, AGGREGATE(15, 6, ROW($1:$3)*SIGN(MATCH("*"&E$3:E$5&"*", A3, 0)), 1))
Note that ROW(1:3) is the position within F3:F5, not the actual row number on the worksheet. I've also scrambled the Find and Insert values in your original cross-reference table to avoid the perception of an associative lookup match.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

If string contains word from list, return value adjacent to list value

Currently I have a set of cells, and each has, among useless information, a unique identifier. I also have a list of these unique identifiers, as well as what value each identifier corresponds to.
What I would like to do is find which, if any, identifier a cell contains, and then output the corresponding value, below is an example:
http://i.stack.imgur.com/97aKI.png
So where the cell contains "ADC", I would like excel to find where ADC comes up in the reference array, and then return the corresponding value.
If this can be done with a formula or a macro, either would be great. I have tried fiddling with index, match, and search, in various combinations, but nothing seems to be working. I have found creating a massive if statement to be impractical as there are about 70 unique values to search for.
Any suggestions would be welcome!
edit: I was recommended to use vlookup, but I am not looking for an identical match, but instead for a specific value contained within a string. If vlookup does have this functionality then could somebody show me how to put this into practice with my specific example?
One method of a 'reverse-wildcard' lookup can be achieved is with the newer AGGREGATE¹ function. This function can produce cyclic calculation and has an option (e.g. 6) to discard errors. Use this to produce a row number on the match to the cross-reference table with the INDEX function returning the actual value.
      
The formula in B3 is,
=INDEX(F$3:F$5, AGGREGATE(15, 6, ROW($1:$3)*SIGN(MATCH("*"&E$3:E$5&"*", A3, 0)), 1))
Note that ROW(1:3) is the position within F3:F5, not the actual row number on the worksheet. I've also scrambled the Find and Insert values in your original cross-reference table to avoid the perception of an associative lookup match.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.

Excel 2003/2007 named formula appears to store only single value not range/array

Similar to a question by Stephen Roy April 26, 2013, answered by Barry Houdini. I have a named range per this generic formula
{=IFERROR(INDEX(Range,SMALL(IF(
MATCH(Range,Range,0)=ROW(INDIRECT("1:"&ROWS(Range))),
MATCH(Range,Range,0)),ROW(INDIRECT("1:"&ROWS(Range))))),"")}
[obviously in 2003 I don't use IFERROR()]
"Range" itself is a named array formula.
The formula is used to pull unique entries from a range and arrange them at the 'top' of another 'range'. However, INDEX() appears to 'store' only a single value, not the array expected. Barry talked about wrapping the ROW() in another function to lose the {array}. It looks as though the first ROW() returns multiple values and works fine, it's the last ROW() which seems to be reduced to the first array entry only, thereby causing INDEX() to return only a single value. However, instead of trying to store this in memory, I select a multi-cell range for output, and use CSE, it works perfectly well. But I don't want to have to do that.
I've tried messing around with INDIRECT(), but can't get that to work at all.
Grateful for your thoughts folks, ian taylor
This might work for you. To return a list of unique values given your range x for example:
=LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)),
ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))),
ROW(INDIRECT("1:"&ROWS(x))),x)
You could define this as a name called Unique and use it in other formulas eg =COUNTIF(x,Unique) returns an array of frequencies.
Addendum
Regarding INDIRECT/INDEX/ROW etc. here's my 2c (see also here). Function inputs and outputs can essentially be divided into three cases: single values, arrays or references. If a function input argument takes single values by default and an array is specified, then the result depends on the type of output of the function. If the output type of the function is:
A) a single value - an array of values is returned, one for each input value. This is the case for most functions eg =LOOKUP({1;2},{1;2;3},{"a";"b";"c"}) returns {"a";"b"}.
B) a reference - an array of references is returned. This is the case for INDIRECT/OFFSET. eg =INDIRECT("A1:A"&ROW()) returns a single element array containing a reference but this can raise errors in many functions as the references are not converted to values by default.
C) an array - a value or array is returned based on the first input of the function if evaluated normally and entered into a single cell. Or else an array is returned based on the first result for each input if entered into multiple cells. This is the case for INDEX which may return an array if one of the arguments is zero. For example =INDEX({1,2;3,4},0,{1;2}) returns {1;3} when evaluated in the formula bar, but {1;2} when array-entered into cells.
In fact Excel uses a variant data type that can take on any of these types so the details are a little more complex than this. Also there is the ability to modify arguments in place which may be why for example VLOOKUP behave like case C with arrays in the first argument but case A with the third argument.
i tried this as a defined name say, "Unique_List" so that i can use it as a Data validation list, but when i add this defined name to the data validation list, it gives an error.
=LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)), ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))), ROW(INDIRECT("1:"&ROWS(x))),x)
where x is my range.
i tried transposing this formula to get the values comma-separated rather than semicolon-separated, but data validation list doesnt seem to work.
=TRANSPOSE(LOOKUP(SMALL(IF(MATCH(x,x,0)=ROW(INDIRECT("1:"&ROWS(x))),MATCH(x,x,0)), ROW(INDIRECT("1:"&SUM(IF(FREQUENCY(MATCH(x,x,0),MATCH(x,x,0)),1))))), ROW(INDIRECT("1:"&ROWS(x))),x))
Kindly advice.

Resources