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.
Related
I have almost 2000 rows of content (all product descriptions for a website rebuild, no data) that I've edited and now need to include a Trademark symbol or Registered symbol on various product names and technologies throughout the worksheet. Using Find and Replace would be the fastest way to accomplish this, but the problem is, I only want the symbol to occur on the first instance of the word in the cell and not any following instances.
For example, if I Find and Replace "Nike shoes" with "Nike® shoes". The result would be:
Nike® shoes are built to last for years. Every pair of Nike® shoes is covered by our full lifetime warranty.
But what I really want is the following:
Nike® shoes are built to last for years. Every pair of Nike shoes is covered by our full lifetime warranty.
Is there any way to create a function for finding and replacing the first instance of a word in a cell?
Just a side note, I've never used excel before now so I'm new to this.
If I understood correctly you can try:
=SUBSTITUTE(Cell of the text, "Old Text", "New text", 1).
1 means that you want only one instance of the word to be replaced.
Example:
Let say the text is in cell A1
Nike shoes are built to last for years. Every pair of Nike shoes is covered by our full lifetime warranty.
=SUBSTITUTE(A1, "Nike", "Nike®", 1)
It worked well for me, for exactly the same problem.
This is not your average vlookup error.
I have two Power Query tables that I've setup. One is coming from a CSV file with a list of names. The other is from a website pulling a list of names.
i.e.
=John Smith = John Smith would not be true for some reason.
They vlookup should be able to find the name easily. I've tried proper,upper, clean, trimming and text to columns and everything else that I could think of. I've changed data types to no avail.
I know that one query is causing the issue. I can type the name exactly and do a vlookup from one, and it works. The second query that I do this to doesn't return anything on the typed text.
Anyone encounter this issue while using Power Query?
EDIT: See Jeeped's Answer - When I replace the space from the web query with a normal space it works.
#Jeeped's comment has a good answer:
Assuming you have already trimmed off leading and trailing spaces, one of the John Smith entries (likely the one from the web) uses a non-breaking space (e.e. CHAR(160) or ASCII 0×A0) instead of a regular space (e.g CHAR(32) or ASCII 0×20). Use
=CODE(MID(A$1, ROW(1:1), 1))
on both, fill down to get a ASCII code for each letter and compare the numbers.
Long-time user of Stack Overflow though couldn't find a clear answer to this
OBJECTIVE: Next to each Product field I need to find and retrieve a matching Brand which substring is in another worksheet.
-Worksheet 1 (Products) I have a single column with 76,000 rows
-Worksheet 2 (Brands) I have a single column with 2,000 brands and growing
Sample Data:
Products
COLUMN A
ANGEL BRAND BLACK OLIVES 2KG
ANMOL SALT TABLE 750GR
76,000 others
Brands
COLUMN A
ANTONELLI
AH
AHG
So the result should fetch a brand from a growing list and dynamically place it in the Products Worksheet:
A1- PRODUCT B1- BRAND
A2- ANGEL BRAND BLACK OLIVES 2KG B2- ANGEL
C2- ANMOL SALT TABLE 750GR C3- ANMOL
I have searched a number of forums and am convinced that the INDEX MATCH Array is what I need to do, though can't seem to get the syntax... it might be that I need to include a SEARCH in there somewhere.
This was the closest thing I found to what I need though couldn't exactly make it work for me: How to find if substring exists in a list of strings (and return full value in list if so)
Thank you for your patience in my explanation... I'll get better at this!
UPDATE: This kinda does what I am after though it takes quite a while to refresh and it's only picking up the first couple of letters as opposed to the entire word:
=IFERROR(INDEX(BRANDS!A:A,MATCH(TRUE,INDEX(ISNUMBER(SEARCH(BRANDS!A:A,A2)),,),0)),"No Match Found")
If the brand name is always included in the Products then, you can try:
=INDEX(Brands!$A:$A,MATCH(1,IF(ISERROR(SEARCH(Brands!$A:$A,A2)),0,1),0))
You enter this formula on B2 using Ctrl+Shift+Enter.
So for example, you have below set-up:
It will give you what you want. Take note though that re-calculation may take a while since you are dealing with a lot of data.
Another option would be to do this using macro which you'll need to run every time you open the workbook.
IMPORTANT: This will fail though if you have brand names like BLACK or OLIVES which is also found on the product name.
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.
I'm attempting to create usernames based off of a given persons first and last name. Generally, we use the first initial and last name for a username. However, now many of our users have 2 last names and sometimes include a hyphen. I am trying to create a code that gives me the first initial, the first letter of the FIRST last name and then the last name.
For example --
Amy Smith-Jones ==
asjones
This is what I am currently using, but, of course, it would yield "asmithjones".
=LOWER(LEFT(A1,1)&SUBSTITUTE(SUBSTITUTE(A2,"-","")," ",""))
I've tried some variations of this, but with no luck.
=LOWER(LEFT(A1,1)&LEFT(A2,1)&SUBSTITUTE(SUBSTITUTE(A2,"-","")," ",""))
Is there a way to generate both the first letter of the first string and the full text of the 2nd string?
EDIT
I came up with something, but now I face another challenge
=IFERROR(LOWER(LEFT(D2,1)&SUBSTITUTE(SUBSTITUTE(RIGHT(F2,LEN(F2)-FIND(" ",F2&" ")),"-","")," ","")),LOWER(LEFT(D2,1)&SUBSTITUTE(SUBSTITUTE(F2,"-","")," ","")))
Some users have 1 last name so this applies if the formula comes across those. But I have some who have a hyphen instead of a space. The SUSTITUTE function accounts for both, but how can I make the FIND function do the same?
Try:
=LEFT(A1,1)&MID(A1,(SEARCH(" ",A1)+1),1)&RIGHT(A1,(LEN(A1)-(SEARCH(" ",(SUBSTITUTE(A1,"-"," ")),(SEARCH(" ",A1)+1)))))
Based on your edit, I'll assume first names are in column D and last names are in column F:
=LOWER(LEFT(D2) & IFERROR(LEFT(F2)&MID(F2,FIND("-",SUBSTITUTE(F2," ","-"))+1,99), F2))
SUBSTITUTE changes spaces to hyphens in the last name, so FIND can look for hyphens only.
IFERROR fails if a hyphen is not found (after substitution), in which case the entire last name is returned.
Example: