I am trying to do a very simple task that does not give me the expected results:
I got the following excel table with columns A and B:
Column A
Mr. John Doh
Mario Bros
Dr. Frankenstein
Mickey Mouse
Donald Duck
Column B
Jenny Dart
john doh
Roger Rabbit
Frankenstein
I am extracting values with VLOOKUP comparing B to A
=VLOOKUP("*"&B1&"*";$A$1:$A$5;1;FALSE)
however the result is the following:
Mr. John Doh
#N/A
#N/A
#N/A
If I do the contrary so comparing A to B:
=VLOOKUP("*"&A1&"*";$B$1:$B$5;1;FALSE)
I get the following result:
#N/A
#N/A
#N/A
Dr. Frankenstein
In both cases I would expect to see "Dr.Frankenstein" and "Mr.John Doh" appearing in both results
however, it seems not the case.
Any idea why?
There are no extra spaces in the cells
There are no Typos in the cells.
I tested the index 1 and the index 2 with no luck.
TRUE cannot be used as I am having "*"
The ultimate goal is to have a long list of users and pulling out data comparing the columns considering that some cells contain title+name like: "Mr." or "Dr."
In the A column you have "Mr. John Doh" and in B "john doh" so when using Vlookup to search john doh in A, it finds it. But in case you are searching "Mr. John Doh" it can't be successful because of the "Mr. " part of the string.
The same case with Frankenstein and Dr. Frankenstein in the other example. Strip the titles ("Dr", Mr. etc) and it will work.
Related
I need a little help: I have to cross match Database A user names(firstname lastname) with Database B where there are some extra characters and the order is last name firstname), so the normal vlookup does not find exact match. I tried the following: I used text to column from the Database A, to have two separate column, then I tried to find the name from Database B
=IF(IF(ISNUMBER(SEARCH(A1,C1)),ISNUMBER(SEARCH(B1,C1))),"yes","no")
This show correct result when the name is in the same line
A1 Tom
B1 John
C1 John dr tom -
The results is true(yes), but in case:
A1 Tom B1 Jon C2 John dr tom - the result are false(No)
I need to same at Database A which is a appearing at Database 2. So I need to find the duplicated items.
Can you help me out how to correctly find what I am looking for?
=VLOOKUP(""&B1&"" &""&A1&"",F:F, 1,FALSE) This was the answer, I managed to figure out.
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.
I am looking for a way to find the match in Column A to B and highlight. I tried many excel formulas in the forum but unlucky in getting it work.
For eg..
**ColumnA**
John23
Peter
Nick5
Kevin4
T12345
ColumnB
John23 is outside the yard
Kevin4 is the famous guy
ABC is with Nick5
Who is the person at the door. is it Peter?
R345 Qrtfjd T12345
Kevin is not the match
Only Kevin4 is the match
John is not the match
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$1:INDEX(A:A,MATCH("zzz",A:A)))/(ISNUMBER(SEARCH($A$1:INDEX(A:A,MATCH("zzz",A:A)),B1))),1)),"")
Say I have the following text string in one single Excel cell:
John John John Mary Mary
I want to create a formula (so no menu functions or VBA, please) that would give me, on another cell
John Mary
How can I do this?
What I've tried so far was search the internet and SO about the issue and all I could find were solutions involving Excel's built-in duplicate removal or something involving countif and the replacement of duplicates for "". I've also taken a look at the list of Excel functions, especially those from the "Text" category, but couldn't find anything interesting, that could be done on one cell.
The answer is here: https://www.extendoffice.com/documents/excel/2133-excel-remove-duplicate-characters-in-string.html
Function RemoveDupes2(txt As String, Optional delim As String = " ") As String
Dim x
'Updateby20140924
With CreateObject("Scripting.Dictionary")
.CompareMode = vbTextCompare
For Each x In Split(txt, delim)
If Trim(x) <> "" And Not .exists(Trim(x)) Then .Add Trim(x), Nothing
Next
If .Count > 0 Then RemoveDupes2 = Join(.keys, delim)
End With
End Function
Put the code above in a module
Use =RemoveDupes2(A2,",")
A2 contains repeated text separated by ,
You may change the delimiter
Assuming you'll never have more than two distinct names in a cell, this should work:
=MID(A1&" ",1,FIND(" ",A1&" "))&
MID(SUBSTITUTE(A1&" ",MID(A1&" ",1,FIND(" ",A1&" ")),"")&" ",1,
FIND(" ",SUBSTITUTE(A1&" ",MID(A1&" ",1,FIND(" ",A1&" "))&" ","")))
It will show John Mary for all of these:
John John John Mary Mary
John Mary
John Mary John Mary
John Mary Mary
John John Mary
It will show John for all of these:
John
John John
John John John
And it will show nothing if A1 is blank.
As I wrote, it is trivial to solve with VBA. If you cannot use VBA, one method is to use helper columns.
Assume: Your string is in A1
Enter the following formulas:
C1: =IFERROR(INDEX(TRIM(MID(SUBSTITUTE($A$1," ",REPT(" ",99)),(ROW(INDIRECT("1:" & LEN($A$1)-LEN(SUBSTITUTE($A$1," ",""))+1))-1)*99+((ROW(INDIRECT("1:" & LEN($A$1)-LEN(SUBSTITUTE($A$1," ",""))+1))=1)),99)),ROWS($1:1),1),"")
D1: =IF(COUNTIF(C1:$C$5,C1)=1,C1,"")
Select C1 and D1 and fill down until you start getting blanks
E1: =D1
E2: =TRIM(CONCATENATE(D2," ",E1))
Select E2 and fill down.
The contents of the last cell filled in column E will be your result.
If you want to have a cell which automatically returns the contents of the last cell in column E range, you can use a formula like:
=LOOKUP(REPT("z",99),$E$1:$E$100)
Without a formula: Text to Columns with space as the delimiter, transpose the output, apply Remove Duplicates to each of the columns individually, then transpose the result.
Found a solution that might work if you are also the one making the list.
when you make the list if you are doing it by combining the cell above with the current line, you can check to see if the value is already in the above cell using the following code:
if(iserror(find(value_to_be_added,previous_concatenation)),
previous_concatenation&" "&value_to_be_added,previous_concatenation)
Did you try the textjoin function? (available in Excel 2016, not sure about previous versions). Was just looking for something similar and this seems to do the job for me on a column where I have multiple values more than once.
=TEXTJOIN(delimiter;ignore_empty;text)
define delimiter in any way you need it
ignore empty can be true or false, depending on what serves your needs
text would be your array of values - using the unique function within here (see example below) will filter out any multiples of any string (I am using it for numbers and it works)
Example:
=TEXTJOIN(" ";TRUE;UNIQUE($A$1:$A$16))
Guess this might be Excel's equivalent to google sheets' join function. Textjoin comes up if you type in =join - I took the formula provided in user11308575's post above but removed the parantheses and its content, then went from there.
Hope this helps (even though the thread is already old) ;)
If one has access to TEXTJOIN one could use:
=TEXTJOIN(" ",,FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[not(preceding::*=.)]"))
I found the answer below in this thread https://superuser.com/questions/643909/remove-duplicate-entries-in-one-cell
=join(" ",unique(transpose(split(A1," "))))
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)