MATCH subtracting afterwards? MATCH (lookup;array;match_type) -1 - excel

The question: if MATCH uses (lookup;array;match type) why there is a -1 after?
I have an Excel sheet at work that uses match in a way I cannot figure out.
The original formula:
=IF(E2<>"";OFFSET('Sheet1'!$A$2;MATCH(E2;Streams;0)-1;0;COUNTIF(Streams;E2);1);ITID)
The break down for the MATCH's part is:
MATCH(E2;Streams;0)-1;
The lookup value "E2" contains selectable values from "Streams", which is a named list. This named list "Streams" contains non numeric values like:
LOG
PLTP
PTP
OTC
etc...

Just understood that Match gives back the number position of the result, not the result itself.

Related

How to reverse Match for cell containing string Excel 2010

From column O I would like to lookup column A, starting from my current row, to find the first cell with a comma. Goal is to have the correct date in each row.
Table I'm working in https://i.imgur.com/BByfjzy.png
=MATCH("*"&","&"*",$A$1:INDIRECT("A" & ROW()),0)
If I could just run it backwards that be great but I'm not finding a way that works with wildcards or contains in excel 2010. My other thought was to make an a range based off position, invert it, find the index and do length - index but I'm not sure how I would go about that. I'm pretty new to excel so any help would be apricated.
=MAX(IF(ISNUMBER(FIND(",",A1:INDEX(A:A,ROW()))),ROW(A1:INDEX(A:A,ROW())),))
Instead of MATCH which looks from top to bottom and returns the first match, use MAX to return the max row number of the cell containing ,. You can use either FIND or SEARCH.
If you wrap it in INDEX you get your value:
=INDEX(A:A,MAX(IF(ISNUMBER(FIND(",",A1:INDEX(A:A,ROW()))),ROW(A1:INDEX(A:A,ROW())),)))
It might require to be entered with ctrl+shift+enter. I'm unable to test it in older Excel version.
Edit for further explanation of how it works:
A1:INDEX(A:A,ROW()) is to be read as cell A1 up to the current row in column A. So if you're at row # 10 it would equal A1:A10.
Wrapping that range in FIND returns the position of the character you try to find.
If given character is not found in the cell it returns error #N/A.
So if you have row 1 and 9 containing , in this case, it returns an array of numbers for the hits and errors for the non-hits, for instance {2,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,6,#N/A}
Wrapping that in ISNUMBER changes the non errors to TRUE and the errors to FALSE.
IF takes that array and in case of TRUE (a number) it returns the row number (same indexed range is used).
Then MAX returns the largest row number of that array.
Instead of FIND you could also use SEARCH. FIND is case sensitive, and SEARCH isn't, further on they operate the same).

Return the index of the last column with a specific name in excel

I'm trying to create an excel register that counts the number of times someone has registered, and returns the date of the last time they turned up but am having trouble with this last step:
See this simplified setup:
To do this, I assume I need to find the index value of the column in which the name last appears, and the use it to return the date in the first row, the tricky part trying to get that index value.
I've tried to use lookup formulas and am pretty sure that an array formula is how this can be accomplished but am unsure how I can use them in this specific case.
Assuming you have Excel 2010 or later:
=INDEX($1:$1,AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1))
Copy down as required.
The explanation is as follows:
The portion:
(A$2:D$8=O2)
simply returns an array of Boolean TRUE/FALSE values as to whether each of the cells within that range is equal to the entry in O2 or not, i.e. using your example:
{TRUE,FALSE,TRUE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,TRUE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE}
The part:
COLUMN(A$2:D$8)
returns the column number for each column within the specified range, i.e.:
{1,2,3,4}
By reciprocating this array with that containing our conditional Boolean TRUE/FALSE returns, we produce an array whose only numerical entries correspond to columns in which our search string (i.e. "James") is located, since:
COLUMN(A$2:D$8)/(A$2:D$8=O2)
which is:
{1,2,3,4}/{TRUE,FALSE,TRUE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,TRUE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE}
becomes:
{1,#DIV/0!,3,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,2,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,4;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!}
by virtue of the fact that, when subjected to a suitable mathematical operation (of which division is one), Boolean TRUE/FALSE values are coerced into their numerical equivalents (TRUE=1, FALSE=0), meaning that, effectively, for any numerical value x:
x/TRUE ⇒ x/1 = x
and:
x/FALSE ⇒ x/0 = #DIV/0!
By setting AGGREGATE's first parameter to 14 (equivalent to the function LARGE) and its second to 6 (instructing it to ignore any errors in the array passed), we can extract the largest column index which meets our criterion, such that:
AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1)
which is here:
AGGREGATE(14,6,{1,#DIV/0!,3,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,2,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,4;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!;#DIV/0!,#DIV/0!,#DIV/0!,#DIV/0!},1)
returns 4.
All that is left is to pass this value to INDEX, such that:
INDEX($1:$1,AGGREGATE(14,6,COLUMN(A$2:D$8)/(A$2:D$8=O2),1))
which is:
INDEX($1:$1,4)
returns:
13/11/2015
as required.
Regards

ms excel 2007, vlookup #n/a error

This question is an extension of this - click me:
So I have 7 ordered checkboxes, generating 128 possible combinations of being checked/unchecked. Each checkbox is linked to a cell showing its state - true =1, false =0.
I then have a cell that concatenates the states of all 7 check boxes into a 7 digit string, e.g. 1000011 or 0000000 or 1110011, etc - providing a lookup value for my lookup table (which designates each possible combination to a piece of text).
The problem I am having is that vlookup is not finding the strings beginning with a leading 1, e.g. 1000001, or 1110000, or 1001110, etc, but strangely is matching one of the strings beginning with a leading 1 - "10000000". In other words, when I select only the first check box of the 7, I get text. When I select the first check box in addition to any combination of the other 6, I get an #N/A. When I deselect the first check box, with any combination of the others, I get text. Odd, I know.
Could anyone help with this?
Thanks in advance.
You might check if format at origin is equal to all values at destination, I mean, if you have for example 1000001 in lookup field as NUMBER and at lookup table you have the same value as TEXT, VLOOKUP never going to find it, because to Excel is not the same thing a value as NUMBER and a value as TEXT.
I'm almost sure that in your lookup table you have some values as NUMBER; to solve it you have to select only the column of your lookup table when you have all the possible combinations, then go to Data -> Text To Columns, then click Next -> Next -> Choose 'Text' Option -> Finish
Let us know if that worked for you.
Short answer: Supply FALSE as 4th VLOOKUP() parameter.
If it is omitted, range search is supposed to be TRUE and in such a case order of items in VLOOKUP() list matters, because they are understood as thresholds, not as singular values.
From VLOOKUP() help:
Lookup_value The value to search in the first column of the table array. Lookup_value can be a value or a reference. If
lookup_value is smaller than the smallest value in the first
column of table_array, VLOOKUP returns the #N/A error value.
And now read carefully:
Range_lookup A logical value that specifies whether you want
VLOOKUP to find an exact match or an approximate match:
If TRUE or
omitted, an exact or approximate match is returned. If an exact match
is not found, the next largest value that is less than lookup_value is
returned.
The values in the first column of table_array must be placed in
ascending sort order; otherwise, VLOOKUP may not give the correct
value. You can put the values in ascending order by choosing the Sort
command from the Data menu and selecting Ascending. For more
information, see Default sort orders.
If FALSE, VLOOKUP will only find
an exact match. In this case, the values in the first column of
table_array do not need to be sorted. If there are two or more values
in the first column of table_array that match the lookup_value, the
first value found is used. If an exact match is not found, the error
value #N/A is returned.

find last match in column using built in functions in excel

I have an excel workbook with multiple instances of the same client ID. So, a client can appear more than once in the list. I would like to find the last (closest to the bottom) instance of the client ID so i can then look along that same row for additional information. VLOOKUP shows the fist instance, I need the last.
So, how do I find the last instance of a given client ID using built in functions? I'd rather not write a macro to do this.
Suppose you want to find last instance of id "id_1" in range A2:A8 and return corresponding value from range B2:B8, then use:
=LOOKUP(2,1/(A2:A8="id_1"),B2:B8)
If you want to return index of last intance of id "id_1" in range A2:A8, use:
=MATCH(2,1/(A2:A8="id_1"))
with array entry (CTRL+SHIFT+ENTER).
If you want to return row number of last intance of id "id_1", use:
=LOOKUP(2,1/(A2:A8="id_1"),ROW(A2:A8))
This syntax is a special trick: (A2:A8="id_1") evaluates to {TRUE,FALSE,FALSE,TRUE,...}. Next, assuming that TRUE=1 and FALSE=0, the part 1/{TRUE,FALSE,FALSE,TRUE,...} gives you {1,#DIV0!,#DIV0!,1,..}.
To return last number in resulting array lookup_value should be greater than any value in lookup_array ({1,#DIV0!,#DIV0!,1,..} in our case). Since array contains only 1 or #DIV0!, we can take 2 as lookup_value, because it's always greater than 1.

Excel: Match returns error

I have this list in excel:
ID (A) | Name (B)
1 | xyz
2 | Yzx s.r.o
3 | xxx a.s.
...
In another list, I have only names and need to assign IDs to them based on the list above.
I use this function =Match(H4; ListName!B2:B50; 0) (H4 cell contains name of company I want to match from other list and get ID for it).
When
there is no match, match function returns #Nedostupný (#Not available)
there is a match, match function returns #Názov? (#Name?)
EDIT: what could cause this problem? Does Match function works with strings that contains whitespaces, dots, or other special characters? Does a column type matter (whether format is set to text or not)... ?
PS: I wanted to get number of row where there is a match and then just select ID from A column of same row. Is there an easier way? How would I combine column Name with row returned from match? something like =A+Match(...)?
Like simoco said above, you might have problem with localized function name.
You should always use fixed references to lookup lists, like this: =Match(H4; ListName!$B$2:B$50$; 0) or this: =Match(H4; ListName!$B:$B; 0) otherwise when you fill the formula down the list reference will also move down: =Match(H4; ListName!B3:B51; 0), =Match(H4; ListName!B4:B52; 0) etc. so it will not contain the data you need.
To combine or rather concatenate strings, use & operator: ="A"&MATCH(...).
Probably you should consider using VLOOKUP() function instead of MATCH() it returns the value from another column based on the search in first column rather than the number position of value you're looking for.
Firstly, the syntax of your function is incorrect - the MATCH function uses a comma (,) as the separator between individual arguments, not semicolons (;).
Secondly, you should use absolute cell referencing for your lookup array in the MATCH function.
Thirdly, you need to ensure that the worksheet in which your lookup array is stored is called ListName (i.e. the same as that referenced in your formula); there shouldn't be any spaces in your worksheet name (e.g. List Name, etc), as this will prevent Excel from referencing the correct worksheet in your workbook [I'm assuming that you are calling the MATCH function from within the same workbook (though not necessarily the same worksheet) as your lookup array].
Hence, your MATCH function should read:
=Match(H4,ListName!$B$2:$B$50,0)
And I've checked this code - it works perfectly for your intended purpose (as described in your question above) when using either Excel 2010 or Excel 2013.

Resources