Partial match when using vlookup formula - excel-formula

I'm trying to fill an empty column of a sheet with data from another sheet. For this I'm depending on VLOOKUP
Here is my formula
=VLOOKUP(RC[-6],Sheet2!C[-3]:C[-2],2,FALSE)
I'm looking for a name in a sheet and takes value from that row. But the issue I'm facing is sometime the value in sheet2 (Where I have to do vlookup) which is actually a person's name doesnt have middle name. It only have first and last name. Since the lookup value as middle name, in that situation the lookup doesn't yields any result. So the plan is to do lookup with the first and lastname only even there is middle name in the lookup value. How can we accomplish that
For example our lookup value (RC[-6]) could be Donald John Trump. But in search sheet (Sheet2) the name could be only Donald Trump. So in result I need Donald Trump row, but it's not since we have Donald John Trump as lookup value.

You can use wildcards in VLOOKUP like the asterisk * for any amount of characters or the ? for one character.
So if your search term is Donald Trump but you want to find also Donald John Trump then you need to add an asterisk Donald *Trump:
=IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=1,LEFT(A1,FIND(" ",A1)-1) & " *" & RIGHT(A1,LEN(A1)-FIND(" ",A1)),A1)
Or if your search term is Donald John Trump but you want to find also Donald Trump then you need to substitute the middle name with an asterisk Donald *Trump:
=IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))=2,LEFT(A1,FIND(" ",A1)-1) & " *" & RIGHT(A1,LEN(A1)-FIND(" ",A1,FIND(" ",A1)+1)),A1)
You can then use the above formula as first argument in your VLOOKUP, or use a helper column so you can see what the actual search term is.

Related

MS Excel: Search, Find and Extract Specific Text Cell containing text string

Although, I've seen relatively similar or close postings
Using MS Excel MS Excel 2010, I would like to be able to search Cell Range (Column A1:A25), to find if specific text within Cell String (Column C2) is a match in Cell Range (A1:A26) and then Output the corresponding matching Keyword results found in same or adjacent cell. If matching text is not found then display "No Match Found"
Although the sample formula shown below that I'm using does work, but only indicates it found or did not find word within Cell Range I need for it to return the actual matching Keyword text found versus "FOUND" OR "NOT FOUND".
=IF(SUM(IFERROR(FIND(A1:A26,C2),0))>0, "FOUND", "NOT FOUND")
Example:
Cell String contains the following text in Cell C2:
"I found a lost German Sheppard in my backyard on yesterday"
Keyword Search Words: Column A1:A26
TYPES OF DOGS
Affenpinscher
Afghan Hound
Airedale Terrier
Akita
Alaskan Malamute
American Foxhound
American Staffordshire Terrier
American Water Spaniel
Anatolian Shepherd
French Bulldog
German Pinscher
German Shepherd
German Shorthaired Pointer
German Wirehaired Pointer
Giant Schnauzer
Glen of Imaal Terrier
Golden Retriever
Gordon Setter
Great Dane
Greater Swiss Mountain
Great Pyrenees
Greyhound
Harrier
Irish Setter
Irish Terrier
The Returned and displayed results/answer = German Sheppard
Please let me know if this possible, as I would greatly appreciate any assistance to resolving my question.
Miaka3
Assuming you are searching column A for a string(s) in column C type this array formula in B:
=IFERROR(INDEX($C$2:$C$6,MAX(IF(ISERROR(FIND($C$2:$C$6,A2)),-1,1)*(ROW($C$2:$C$6)-ROW($C$2)+1))), "None")
You can see here that I have a search list of multiple characters/strings in C2 through C6. If one of the search strings is found, it will be listed in column B, otherwise it will display "None".
The key to this working is copy the above formula into cel B2 and while you are still in edit mode pressing Ctrl+Shift+Enter instead of just Enter like usual. You will know it works correctly if you see the addition of { and } in the formula once you hit the three key combination. After that you can copy the formula down through A25 or wherever you need.
Note you can make your Search List longer or shorter as needed, just make sure to update your formula to reflect the range. You will want to fill in all of you dog breeds in Column C and change every $C$2:$C$6 in the formula to equal your search list range. And, remember, any change to the array formula requires Ctrl+Shift+Enter to work properly.
This isn't what Excel was designed for, but you can accomplish it with a helper column. Insert a new column at B (this will move C2 to D2). Then paste this formula into B2:
=IF(ISERROR(FIND(A2,D$2)),"",A2)
Fill down that formula until A27 (you said A26, but your example went to A27 if you include the header "TYPE OF DOGS"). This will output the breed of the dog only if it is contained within the text in D2.
Finally, go to whatever cell you would like to contain your output, and paste in:
=CONCATENATE(B2,B3,B4,B5,B6,B7,B8,B9,B10,B11,B12,B13,B14,B15,B16,B17,B18,B19,B20,B21,B22,B23,B24,B25,B26,B27)

adding wildcard to look up formula?

I am using the following formula as part of a multi result look up function. I have several of these formulas posted into one row each beneath the other, so if I type catering into cell K22 on sheet 1 my formula then looks up that matching word from column b on sheet 2 and produces the name in column a. The formula also includes duplicating this lookup a few times to fetch other values from other columns with the same matching result.
so for instance my columns on sheet 2 look like:
Name Description Location Number
Amy hotel london 1
Dave hotels manchester 2
Mike catering Birmingham 3
What I want to do is to use wild cards around my cell K22 in this formula to show if the descripion word I type in is like hotel; i.e. hotels, hote ... etc then find the result?
...
I know this can be done using index match but can I use them with the following code I have? at the moment this is an array formula but I get no result when I try to do it like this. can someone show me where I am going wrong, tanks
=IF(ISERROR(INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),1)),"",INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),1)) & " - " &IF(ISERROR(INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),3)),"",INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),3)) & " - " &IF(ISERROR(INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),4)),"",INDEX(Sheet2!$A$1:$D$7,SMALL(IF(Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*",ROW($B$1:$B$7)),ROW(1:1)),4
Although you can use wildcards in the lookup value within a MATCH function (and in other contexts), you can't use them here. When using wildcards with a direct comparison with = like you have, i.e.
Sheet2!$B$1:$B$7="*"&Sheet1!$K$22&"*"
the * is interpreted as a literal asterisk not a wildcard
Replace all instance of the above with this
ISNUMBER(SEARCH(Sheet1!$K$22,Sheet2!$B$1:$B$7))

vlookup return #N/A - String of text in lookup cell

I have an issue. I have 2 large tables of student payments that I need to "reconcile" with each other.
In Table 1, I have students full name, formatted "Smith, John ". I'm using a formula to just return the last name formatted "SMITH".
In Table 2, the students name is at the end of a long string of text which typically looks like this:
VAED TREAS 310 DES:XXVA CH33 ID:xxxxxxxxxxxxxxx, INDN:COLLEGE I WORK FOR CO ID:xxxxxxxxxx CCD, PMT INFO:REF48CH33 TF VA FILE NO xxxxxxxxx *TE, RM xxxxxx-xxxxxx JOHN A SMITH -
Whenever I try to use vlookup for "SMITH", and reference the cell in the second table, I consistently get an #N/A error.
I've uploaded a specific example of what I'm doing here.
You need to create a column within the same table that returns SMITH. In the workbook you uploaded, your VLOOKUP formula was referencing a load of blank cells so it couldn't find SMITH in the left-hand most column.
I made a couple of changes and re-uploaded the workbook for you here:
http://we.tl/WjDiLtHDnm
Table 1 now has the surname added to the very final column. I adjusted your vlookup formula to now use the index and match functions to do what you were intending. The only reason I didn't use Vlookup is that I put the surname on the far right (Vlookup only works referencing from the left hand most column and returning values in columns to the right).
B

Excel - Replace cell value based on a value in another column

I am wondering if there is a way to replace a cell value from another list without having to write a VB script.
Here is the problem I am trying to resolve:
I have last names in a column:
Smith
Jones
Taylor
etc.
I have another column with IDs e.g.
Smith_ID
Taylor_B
Jones_C
I would like to replace Smith with Smith_ID, Jones with Jones_C etc. Obviously my list is much longer than 3 entries.
He can do it.
Extract column IDs with "_" character by "Text to Columns"
A column
Smith
Jones
Taylor
B column
Smith
Taylor
Jones
C column
ID
B
C
Now write to following formula
=CONCATENATE(A1;"_";VLOOKUP(A1;$B$1:$C$3;2;FALSE))
I hope you do
If you have a common value between the 2 lists, then you can use Vlookup() (see link for better examples) to match the 2.
Using your example, you have Sheet1 that says:
Smith
Jones
Taylor
In Sheet2, you have:
Smith 4
Jones 9
Taylor 6
Then do this:
In Sheet1, add a column with the formula =vlookup(A1,Sheet2!$A$3:$B$3,2,False). This will return 4 for the 1st row, 9 for the 2nd, etc.
(Optional) If you want to get rid of the original values completely, you can then copy&paste values and delete the original column OR just hide the original column.
Is this what you're looking for?
To answer this question under general situation, suppose you have two columns as followed:
A Smith,Jones,Taylor,Kevin,Yell,Ashton...
B John Harvard, Yell USC, Kevin Cruise, Ashton Bond, Smith Stone, Taylor Shift...
The classic case here is that you have two pretty much alike columns only with slightly difference. It could be a typo or some other mistakes.
What you want to do is to replace cells'value in column A by them in column B, if we assume that column B is the right thing you want.
So for each cell in A, you want to know the position of its approximate match in column B. For example, given A1(Smith), you want to know where Smith Stone is, in this case, B5.
Begin with a new column C, combined with match function and wildcard, filled C1 by the following formula:
row_index=match(A1&"",$B$1:$B$6,0)
you now extract row_index of every approximate match corresponding to column A. Then by using
=index($B$1:$B$6,row_index,0)
which returns you "Smith Stone" in cell C1. Same for other cells.
*Remark: The biggest flaw for this method is that it kind of requires the approximate match in B for each cell in A should be unique.
I had 2 columns, one was an Vendor Name, the 2nd was the Vendor Address but it also contained the Vendor Name. I needed to strip out the Vendor Name which would leave me with the Vendor Address without the Name.
For example if one column had "Con Ed", the next column had "Con Ed 123 Street, New York, NY 11111", I needed to replace "Con Ed" with null and just have "123 Street, New York, NY 11111" in a column.
Here's what I did and I will also let you know what you can do to accomplish your goal.
First I created a new column and set that to the Length (using the LEN() function) of the Vendor Name.
Then I created another new column and set that to the length of the Vendor Address.
A third column and was set to use the Right() function. Where the text is the Vendor Address and the length is the Length of the Address minus the length of the Vendor Name.
So consider: "Con Ed 123 Street, New York, NY 11111"
1st column: (Length of Vendor): len(Con Ed) = 6
2nd column: (Length of Vendor address): len(Con Ed 123 Street, New York, NY 11111) = 37
3rd Column: Right([Vendor Address], 31 (37-6)) = ", New York, NY 11111"
Lastly I just applied the TRIM function to the 3rd column.
In your case you would just want to use the Concatenate function to append the the original column & the new column.
So in summary you'll have the below columns:
Column 1: Names:
(Smith,Jones,Taylor)
Column2: IDs:
(Smith_ID,Taylor_B,Jones_C)
Column3: Len([Names])
Column4: Len([IDs])
Column5: The "replace" function
= TRIM(Right([IDs], ([Column4] -[Column3] ))
Column6: String put back together
=Concatenate([Column3],[Column5])
=INDEX('All_Linguists_All_ProjectsFri J'!$DA$2:'All_Linguists_All_ProjectsFri J'!$D$71355,MATCH(A2,'All_Linguists_All_ProjectsFri J'!C:C,FALSE),1)
Dont have time to explain it, but if you know how to write formulas in excel, this should be useful. Sorry for not explaining.
Hope you are using excel and in that you want to replace value of one cell of raw from another cell of same raw and this has to be done for entire column and not form selected raw.
In this case you can copy the values which you want to kept (i.e. ID column) and then pest the same in column Last name.
If values are in same raw then there is no problem and from your query it appears that values are in same raw.
I use this formula when searching cell B1 for the letter "s", if found then I concatenate the word "addition" to the value of cell A1 otherwise just take the value of cell A1.
=IF(ISNUMBER(SEARCH("s",B1))=TRUE,CONCAT(A1, " addition"),A1)

How can I switch a string from "lastName, firstName" to "firstName LastName"?

I have a column full of names written as:
"lastName, firstName"
I want to have a nother column that has this name list written as:
"firstName LastName"
So, how can I switch a string from "lastName, firstName" to "firstName LastName" ?
If the first name is in A2 try this formula in B2 copied down
=MID(A2&" "&A2,FIND(" ",A2)+1,LEN(A2)-1)
Enter data into cells e.g.
Brown, John
Green, Bob
Smith, Will
(Note that the comma in this case is the delimiter which the system will use to separate the entries)
Highlight these cells.
Click on the "Data" tab,
click on "Text to Column".
Choose options offered.
The worked for me
=RIGHT(C3,LEN(C3)-LEN(LEFT(C3,FIND(",",C3)-1))-1) & " " & LEFT(C3,FIND(",",C3)-1)
Barry's answer is correct, if the single cell (A2) doesn't ALSO contain errors like "firstname lastname" -- as is often the case.
So, to deal with the cell data being either "Last, First" or "First Last", we'll need to compare the cell and take action appropriately. Also note, in my example, I moved the first name to it's own column, and last name to it's own column. You can of course join them into a single column.
First, let's break down what we need. This will return the first name when there is a "," in the cell contents: (assumes the field you are wanting to split is in A2, adjust as needed)
=MID(A2;FIND(",";A2)+2;99)
and this will return the first name when there isn't:
=MID(A2;1;FIND(" ";A2))
And for Last name when there is a comma:
=MID(A2;1;FIND(",";A2)-1)
and last name when there isn't:
=MID(A2;FIND(" ";A2)+1;99)
So, we need to test if there is a "," in the string, and deal with an error condition when there isn't (FIND returns #value when not found, ISERROR() can test for that). Optionally (and my approach) was to check if the return of the FIND yielded a number (an error won't). In this case, an "error condition of not finding it" would yield a non-number #Value.
=IF( ISNUMBER( FIND(",";A2)); MID(A2;FIND(",";A2)+2;99); MID(A2;1;FIND(" ";A2)))
Doing the same thing for the Last name looks like this:
=IF( ISNUMBER( FIND(","; A2)); MID(A2;1;FIND(",";A2)-1); MID(A2;FIND(" ";A2)+1;99))
Please note that my solution was using my spreadsheet application OpenOffice. I think Excel has a different find method (Search?) - so make adjustments as necessary.
The above answer is incorrect.
In fact, for my own name, Jay Jacob Wind, the formula breaks.
The correct formula is:
Assuming Last, First is in column A, separated by one comma and a space bar
For first name:
=mid(A2,find(",",A2)+2,99)
For last name:
=mid(A2,1,find(",",A2)-1)
Put together, assuming Column B is First Name and Column C is Last Name
=B2&" "&C2
or simply (but more complexly)
=mid(A2,find(",",A2)+2,99)&" "&mid(A2,1,find(",",A2)-1)
but I like separating them into two columns,
then concatenating them

Resources