I have a spreadsheet which contains 'unique' IDs. The problem is that they are only case sensitive unique, meaning that I have: a06D000000QO5uW & a06D000000QO5uw.
I want to perform a vlookup on these IDs and pull back a related value. It's possible to do case sensitive matching using this article I found:
http://support.microsoft.com/kb/214264
The problem I have found is that because the vlookup is nested within the Exact function, it returns the first match it finds, which may not be the one I am after. If I use the data sample from the article, it looks like:
Name Age Joe
Mary 32
joe 48
Bob 53
Sue 27
Joe 30
and the look up looks like:
=IF(EXACT(C1,VLOOKUP(C1,A1:B6,1,FALSE))=TRUE,VLOOKUP(C1,A1:B6,2,FALSE),"No exact match")
The problem seems to be that the vlookup to test "Joe" comes across "joe" first of all and because it isn't case sensitive returns that as a match - meaning it never gets to "Joe". The exact function then fails because it is trying to test "Joe" against "joe".
Is there any way around this? I really wanted to avoid going down the VBA route because we have a mix of Mac and Window users and so I wanted to keep it to formulas.
Your problem (with this exact example) is covered here
The array formula (press Ctrl ShiftEnter
) together will return 30 against joe (NA if no match is found). =INDEX(B1:B6,MATCH(1,--EXACT(A1:A6,C1),0))
A more straightforward formula mentioned in the same article is =LOOKUP(1,1/EXACT(A1:A6,C1),B1:B6)
I think that there is a slightly better way as it does not use an array formula.
=INDEX($B$2:$B$6,MATCH(TRUE,INDEX(EXACT(C1,$A$2:$A$6),0),0))
Related
I have a list of addresses, such as this:
Lake Havasu, Lake Havasu City, Arizona.
St. Johns River, Palatka, Florida.
Tennessee River, Knoxville, Tennessee.
I would like to extract the State from these addresses and then have a column showing the abbreviated State name (AZ, FL, TN etc.).
I have a table that has the States with their abbreviation and once I extract the State, doing a simple INDEX MATCH to get the abbreviation is easy. I don't want to use text-to-columns because this file will constantly have values added to it and it would be much easier to just have a formula that does the extraction for me.
The ways I've tried to approach this that have failed so far are:
Some kind of SEARCH() function that looks at the full State list and tries to find a value that exists in the cell
A MID or RIGHT approach to only capture the last section but I can't work out how to have FIND only look for the second ", "
A version of INDEX MATCH but that fails because I can't find a good way to search or find the values as per approach (1)
Any help would be appreciated!
Please try this formula, where A2 is the original text.
=FILTERXML("<data><a>" & SUBSTITUTE(A2,", ","</a><a>") & "</a></data>","data/a[3]")
An alternative would be to look for the 2nd comma as shown below. Note that the "50" in the formula is an irrelevant number required by the MID() function. It shouldn't be smaller than the number of characters you need to return, however.
Char(160) is a character that wouldn't (shouldn't) naturally occur in your text, as it might if the text comes from a UNIX database. You can replace it with another one that fits the description.
=TRIM(MID(A2, FIND(CHAR(160),SUBSTITUTE(A2,",",CHAR(160),2)) + 1,50))
The following variation of the above would remove the final period. It will fail if there is anything following the period, such as an unwanted blank. That could be accommodated within the formula as well but it would be easier to treat the original data, if that is an option for you.
=TRIM(MID(LEFT(A2, LEN(A2)-1), FIND(CHAR(160),SUBSTITUTE(A2,",",CHAR(160),2)) + 1,50))
To find the abbreviation I would recommend to use VLOOKUP rather than INDEX/MATCH.
Use this (screenshot refers):
=MID(MID(B3,1,LEN(B3)-1),SEARCH(",",B3,SEARCH(",",B3,1)+1)+3,LEN(B3))
I have a multisheet excel file where I am in sheet3 and trying to find the data for a person in sheet2 but it doesn't match correctly, it gets the data of another person.
So I am trying to get the number of days for "Tim" from sheet2:
but is shows like that:
The code is I used was =VLOOKUP($B81,sheet2!$A$2:$M$281,2)
try
=VLOOKUP($B81,sheet2!$A$2:$M$281,2,FALSE)
or
=VLOOKUP($B81,sheet2!$A$2:$M$281,2,0)
if you want exact match.
The last argument of the VLOOKUP function determines the nature of your look up.
1 - TRUE will return an approximate match which is useful when you want to look up a value from group of ranges in ascending order;
0 - FALSE will return an exact match which will return the first match based on your look up criteria.
If you do not input the last argument in your formula, Excel will presume you want to use 1 - TRUE and do an approximate match which will look up the closest (and smaller) match of Tim such as Sam which is considered ahead of Tim and return the value corresponding to Sam instead. However, if your formula is =VLOOKUP($B81,sheet2!$A$2:$M$281,2,) with a comma , at the end of 2, Excel will presume you want to use 0 - FALSE and do an exact match.
Terry W already answered about the exact match, however here you go for some more trail which helps you to work with v-look up easier way.
Table Of RAW Data
Table Of Sheet 2, where we need values of TIM
Trail 1 (Used For Jan):
=VLOOKUP(B4,Raw!A1:M4,2)
Which is worked without using exact match function, as you tired.
Trail 2 (Used For Jan):
VLOOKUP(A4,Raw!A1:M4,2,0)
Which is worked using exact match function as "0", as you tired.
Trail 3 (Used For Jan):
=VLOOKUP($B10,Raw!$A$1:$M$4,MATCH(C$9,Raw!$A$1:$M$1,0),0)
Here instead of using the Index_Num Used match function and used Exact Match Argument too. The match function helps to get exact value of the month, and which make work easier instead of mentioning the Index_Num as 1 and 2 and 3 and Ext... for next and next months. Below snap is for your view.
Please let me know if need any more clarification need on this.
I've got two lists of people and I have to check if they're in both lists. The thing is that characters are not accepted in one of the lists ("-" for instance), and the person might have omitted a last name in case they have two.
For example:
A1 B2
John Paul John Paul Jones
Mary Williams Ryan Roberts
Ryan Roberts-Johnson Mary Williams
My formula is: =IFERROR(MATCH($A1,$B$1:$B$1215,0),IFERROR(MATCH(LEFT($A1,FIND(" ",$A1,1)),$B$1:$B$1215,0),"No Match"))
The idea is: if the name is the same, bring me the line where the person is. If not, look for the first name and see if you find someone with this first and bring it to me. If neither works, reply with "No Match".
But apparently the Match function only retrieves exact matches, so the First Name one doesn't work.
Is there any other way to solve this?
EDIT1: First finding: I can use the SUBSTITUTE formula to replace - with space and do the search once again.
Some of the things I did to save up some time (I probably spent more time figuring out/researching than I would have if I had done ~3500 entries manually, but the learning opportunity was great.)
What I wanted:
To search for for a cell with name + surname when I only had the surname.
What I did: I remembered about the wildcards and used them with VLOOKUP:
First I got the last name and added the star: ="*"&RIGHT($A1,LEN($A1)-FIND(" ",$A1,1))
=VLOOKUP(A1,$B$1:$B$1000,1,FALSE)
And it would try and find the first one. Before that I added a check to make sure that there weren't two people with the surname (so it wouldn't throw another person there) with a simple IF(COUNTIF($C$2:$C$2000,$D219)<=2, and then the rest of the formula.
Something else that I noticed and serves as a reminder: TRIM is very important, as some of the cells had two spaces in between first name/last and some one space after the last letter of the last name. Using TRIM to create a new column made me avoid a lot of mistakes I only took a while to notice.
I believe the case is solved.
You could create a temporary column extracting the first name from B column.
See this example.
While I can extract the first word from a cell containing multiple text values with error checking to return the only word if no multiple values exist. I cannot seem to wrap my brain around adding more checks (or if it is even possible in the same nested formula) for situations where some of the source cells contain a comma between multiple words. Example, the formula below will return "James" from "James Marriott". But, it returns "James," from "James, Marriott". If all of my cells in the range were consistent that would be easy, but they aren't. Attempts to nest multiple find statements have resulted in failure. Suggestions?
=IFERROR(LEFT(A1,FIND(" ",A2)-1),A2)
To compound matters, there are also cells that contain abbreviations as the first word, so somehow I need to account for that as well. For example "J.W. Marriott" where I need to apply the above logic to extract "Marriott".
Here are some examples below:
Text Desired output
James Marriott James
James, Marriott James
Able Acme Able
Golden, Eagle Golden
J.W. Marriott Marriott
A.B. Acme Acme
you could use regex (to set up please look at the post here)
Then you can extract the desired word with a formula like:
=regex(A1, "(?![Etc])[a-zA-Z]{2,}")
(This is searching for a pattern of two or more lower or upper case letters in the cell A1...and not searching for Etc)
I have 2 column data in Excel like this:
Can somebody help me write a formula in column C that will take the first name or the last name from column A and match it with column B and paste the values in column C. The following picture will give you the exact idea what I am trying to do. Thanks
Since your data is not "regular", you can try this formula which uses wild card to look for just the last name.
=INDEX($B$1:$B$4,MATCH("*" &MID(A1,FIND(" ",A1)+1,99)&"*",$B$1:$B$4,0))
It would be simpler if the first part followed some rule, but some have the first initial of the first name at the beginning; and others at the end.
Edit: (explanation added)
The FIND returns the character number of the first space
Add 1 to that to get the character number of the next word
Use MID to extract that word
Use that word in MATCH (with wild-cards before and after), to find it in the array of email addresses. This will return it's position in the array (row number)
Use that row number as an argument to the INDEX function to return the actual email address.
If you want to first examine the email address, you will need to determine which of the letters comprise the last name. Since this is not regular according to your example, you will need to check both options.
You will not be able to look for the first name from the email, as it is not present.
If you can guarantee that the first part will be follow the rule of one or the other, eg: either
FirstInitialLastName or
LastNameFirstInitial
Then you can try this:
=IFERROR(INDEX($B$1:$B$4,MATCH(MID(A1,FIND(" ",A1)+1,99)& LEFT(A1,1) &"*",$B$1:$B$4,0)),
INDEX($B$1:$B$4,MATCH( LEFT(A1,1)&MID(A1,FIND(" ",A1)+1,99) &"*",$B$1:$B$4,0)))
This seems to do what you want.
=IFERROR(VLOOKUP(LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&LOWER(MID(A1,1,1))&"*",$B$1:$B$4,1,FALSE),VLOOKUP(LOWER(MID(A1,1,1))&LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&"*",$B$1:$B$4,1,FALSE))
Its pretty crazy long and would likely be easier to digest and debug broken up into columns instead of one huge formula.
It basically makes FLast and FirstL out of the name field by splitting on the space.
LastF:
=LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))&LOWER(MID(A1,1,1))
And FirstL:
=LOWER(MID(A1,1,1))&LOWER(MID(A1,(SEARCH(" ",A1)+1),LEN(A1)))
We then make 2 vlookups for these by using wildcards:
LastF:
=VLOOKUP([lastfirst equation from above]&"*",$B$1:$B$4,1,FALSE)
And FirstL:
=VLOOKUP([firstlast equation from above]&"*",$B$1:$B$4,1,FALSE)
And then wrap those in IfError so they both get tried:
=IfError([firstLast vlookup],[lastfirst vlookup])
The rub is that's going to be hell to edit if you ever need to, which is why I suggest doing each piece in another column then referencing the previous one.
You also need to be aware that this answer will get tripped up by essentially the same name - e.g. Sam Smith and Sasha Smith would both match whatever the first entry for ssmith was. Any solution here will likely have the same pitfall.