MATCH function does not work with words that have wildcards (*) - excel

I am trying to match HA24BB-3-1LL with HA24B*-3-1** in Excel. Another example is matching HA24FB-3-1LL with HA24F*-3-1**.
However, when I performed the regular match function, these could not be matched.
col A col B
1 HA24BB-3-1LL HA24F*-3-1**
2 HA24FB-3-1LL HA24B*-3-1**
What I tried:
=MATCH(A1,B:B,0)
It should return 2 but it returns #N/A.
May I know why?
I thought Excel match function works with wildcard. Is there a way to enable it?

You can match with wildcards, but the wildcards have to be in your lookup value (first position in the formula). If they are in the lookup array (second position in the formula) they are not wildcards, just literal *s in the cell values.
So you can find matches to strings like HA24B*-3-1** in your first column by using the formula: =MATCH(B1,A:A,0), but not the other way around, as your formula is set up.
Also, if you are looking for things that match HA24B[one character]-3-1[two characters] your search string should instead be HA24B?-3-1??. The * will match a string of any length, so it is redundant to put two of them at the end of your search string, and using them will also find you matches to strings like HA24Babcdedfghijklmnopqrstuvwxyz-3-1abcdefghijklmnopqrstuvwxyz. Which may be what you want, and if it is leave it as is (minus the second * at the end). The ? matches a single character, which I am assuming is what you are looking for since you used ** in your question.

Related

Excel - VLOOKUP return based on partial string

I am trying to get VLOOKUP to return a value based on a partial string. So I want to say: look up this string, look in the list and if you find a partial string matching it, return the date next to it. But not having much luck. In my example, B2 should show: April 9th as the first bit of the string in D2 matches.
Try this one... Will help you
=VLOOKUP(LEFT(A3,FIND(" ",A3,FIND(" ",A3)+1)-1),$D$3:$E$5,2,0)
Use:
=VLOOKUP(MID(A2,1,FIND(" ",A2,FIND(" ",A2)+1)-1),$D$2:$E$4,2,FALSE)
Results:
Or you can do the other way around and use combination of INDEX and MATCH (with wildcard match) - look at the picture:
=INDEX($D$1:$E$4,MATCH(D2&"*",$A$2:$A$4,0)+1,2)
INDEX MATCH example
Advantage is of this is that you do not assume a given pattern of your values. So it does not matter whether it is SPXL APR19 59P or SPXL APR19_____59P.
You can also use the asterisk on both sides "*"&[]&"*", so then you'll do an inside search.

Excel string comparisons with escape character, using boolean, match or sumif

When I was handeling a text-comparison in my database I noticed some odd behavior. In my database I want to SUM values based on a column containing strings. In this example, I want to make a group str and a group txt, with the following string values.
str 2
str1 1
str2 0
txt 1
txt1 2
tx2 3
If I would compare the text with a simpel boolean, i.e. =("str"="str*"), it returns False, because the * is an additional character. This makes sense in some way. However, when I used two other techniques the comparison is handled differently:
First, the following simple SUMIFS function:
=SUMIFS(B:B;A:A;"str*") and =SUMIFS(B:B;A:A;"txt*") includes the values at "str" and "txt" respectively, suggesting the comparison is True.
Second, =Match("str*";{Cell containing "str"};0) returns 1, indicating that the comparison also returns True.
Why does the boolean string comparison return False, whilst MATCH and SUMIFS assume True?
In my opinion those two functions apply the wildcard interpretation of the asterisks while your direct comparison formula with '=' takes it as just another (extra) character in the string inside the quotes, so making the two strings different.
While in the function Match():
If match_type is 0 and lookup_value is text, lookup_value can contain the wildcard characters asterisk (*) and question mark (?). An asterisk matches any sequence of characters; a question mark matches any single character.
I hope this makes sense.
Only a limited number of Excel worksheet functions can use wildcard characters to filter results. Functions like COUNTIF ,VLOOKUP, MATCH and others as listed here are some Excel functions that use wildcards.
Apart from the functions listed in the link, wildcard * is treated like a literal when used in the double quotes.

Using Excel's FIND Function to search for wildcard characters

I would like to extract a substring to the right of a ** by using the FIND function. However, when I use the following formula,
=RIGHT(A2, FIND("~**", A2))
I receive the #VALUE error message. My understanding is that to search for wildcard characters in Excel strings, you must precede the wild-card with a ~ so I don't get why this formula does not work. Please see the attached image for the string and substring (intended) fields.String and Substring fields
Use the following:
=TRIM(RIGHT(A2,LEN(A2)- FIND("**", A2)-1))
You have to subtract Find() from the length of the string -1
Find will give the position of the first *
Right will count from end of string
It means you have to count tne number of character from the last to before *
Consider:
=MID(A2,FIND("**",A2)+2,9999)

MS Excel: remove number of characters after a specific character in a string

I have a column with values like
WI60P-14E64F5167E6-01138
or
WI60-34D03E185267-01051
etc....
i need to find the first occurrence of - till the second occurrence of - and remove the resulting character.
I am using this function =MID(A1,FIND("-",A1),13) which returns me -34D03E185267 or -14E64F5167E6 from the above strings.
But I want the output like WI60P-01138 or WI60-01051
Can anyone help me?
Assuming that the length of text between the two hyphens never varies, you can use your existing function, along with SUBSTITUTE to get the desired string, like so:
=SUBSTITUTE(A1,MID(A1,FIND("-",A1),13),"")
Alternately, you can use FIND to get the hyphen positions and again use SUBSTITUTE to get the replaced string, like so:
=SUBSTITUTE(A1,MID(A1,FIND("-",A1),FIND("-",A1,FIND("-",A1)+1)-FIND("-",A1)),"")
Notice that one of the FIND expressions takes 3 parameters - by passing FIND("-",A1) + 1 as the third parameter, we get the second occurence of '-' within the cell.
This will work for any position of the two hyphens:
=CONCATENATE(MID(A1;FIND("-";A1)+1;FIND("-";A1;FIND("-";A1)+1)-FIND("-";A1)-1))
Solution using multiple cells as support (with dynamic length of the string):
Put this in cell B1 to obtain the first part of the code:
=MID(A1,1,FIND("-",A1)-1)
Put this in cell C1 to obtain the last part of the code:
=MID(A1,FIND("-",A1)+1,LEN(A1))
Put this in cell D1 to concatenate both and get your result:
=concat(B1,C1)
Solution in a single cell (with dynamic length of the string)
Put this in cell B1 to get the same result as above :
=concat(MID(A1,1,FIND("-",A1)-1),MID(MID(A1,FIND("-",A1)+1,LEN(A1)),FIND("-",MID(A1,FIND("-",A1)+1,LEN(A1))),LEN(MID(A1,FIND("-",A1)+1,LEN(A1)))))

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