+ Reply to Thread
Results 1 to 47 of 47

SEARCH function for multiple variables - VLOOKUP?

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Exclamation SEARCH function for multiple variables - VLOOKUP?

    Hello All, I'm a forum virgin and have been going crazy trying to solve a problem. I hope this wont be but I believe this is a tough one!

    I have a large database of email addresses. I want to return the country, company name and first name and remove emails containing certain "bad" words. e.g. "unsubscribe".

    Purpose to upload to my database. Most of this can be obtained using the SEARCH function. i.e. if the cell contains ".co.uk" then return "United Kingdom". I started manually adding them to formula but with nearly 200 variables this has already become unmanageable.

    e.g. =IF(ISNUMBER(SEARCH("*.za*",C2)),"South Africa",IF(ISNUMBER(SEARCH("*.mu*",C2)),"Mauritius",IF(ISNUMBER(SEARCH("*.ke*",C2)),"Kenya" etc etc etc.

    I can apply this to the other fields. For first name though there are potentially 1000's of variables!

    So my thought is, can I combine the SEARCH and VLOOKUP functionality, so I just make a list of variables rather that putting them into a formula.

    For "First Name" I started this one =IF(ISNUMBER(SEARCH($G$2,B2)),$G$2,IF(ISNUMBER(SEARCH($G$3,B2)),$G$3,IF(ISNUMBER(SEARCH($G$4,B2)),

    So it does look at a list but for me to lengthen this formula to hundreds is too fiddly and time consuming.

    Or is there a much easier way?!

    This would save hours of manual work if I can crack it :-)

    Fingers crossed!

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi,

    If you list all your search strings (without the "dot") and their corresponding countries in a separate table, e.g. Sheet2 A1:B3, then your formula would become:

    =LOOKUP(17^17,SEARCH("*."&Sheet2!$A$1:$A$3&"*",C2),Sheet2!$B$1:$B$3)

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    That's fantastic.

    Please explain the 17^17 part, what does 17 refer to?

    I have extended the search range of the formula =LOOKUP(17^17,SEARCH("*."&Sheet2!$A$1:$A$500&"*",C4),Sheet2!$B$1:$B$500)

    How do I make it return a blank if it doesn't find a relevant search field? i.e. not #N/A. normally I put ,"" at the end.

    Can I apply this to First Name, company name etc?

    What if I have Andrew, Andre, Andrea. I will sort them alphabetically. Will it return Andre for Andrew?

    You're a star!

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    "Please explain the 17^17 part, what does 17 refer to?"

    It doesn't refer to anything. It's just an arbitrarily large number of my choosing; sufficently large, in fact (32,767 would actually be the 'correct', i.e. smallest sufficient choice), so that we are sure that all possibilities are accounted for within the SEARCH formula.

    "How do I make it return a blank if it doesn't find a relevant search field? i.e. not #N/A. normally I put ,"" at the end."

    =IFERROR(LOOKUP(17^17,SEARCH("*."&Sheet2!$A$1:$A$3&"*",C2),Sheet2!$B$1:$B$3),"")

    "Can I apply this to First Name, company name etc?"

    Sorry - not sure what you mean by this.

    "What if I have Andrew, Andre, Andrea. I will sort them alphabetically. Will it return Andre for Andrew?"

    I though we were talking countries here? A good point, and no, providing you sort them alphabetically you will be ok, since LOOKUP will return the result corresponding to the last (partial) match found.

    Regards

  5. #5
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Countries - First Name - Entity - Company name i.e. [email protected]. I want to run If searched like with the country one. So I can pull out South Africa (.za)- Robert - Higher Education (.ac) - Shell.

    I also will do something similar to remove email addresses containing given words i.e no-reply, unsubscribe.

    I have a piece of software that pulls emails from my outlook. I have 60,000 email addresses that I am trying to associate all of the above where I can! So I'm using assumptions in some cases like first name.

    Hope this makes sense? I could attach the spread sheet as it is?

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    I think it would help enormously if you could attach an actual spreadsheet. Obviously replace any confidential/sensitive information with dummy data if necessary.

    If you could outline a few examples and, importantly, your desired results in each case that would be great.

    We should be able to use other formulas to extract say First Name, Last Name, etc.

    Regards

  7. #7
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Exclamation Re: SEARCH function for multiple variables - VLOOKUP?

    TO SEND.xlsx

    Please find attached.

    Note this also contains my shockingly bad ways of doing this. I'm sure you'll laugh at columns N> !

    On sheet2 I need to remove the blank spaces before the country names.

    I obviously need to find a first names database. I'm worried about ones like, Jon and Jonathan. I want to be able to add new names and countries etc on an ongoing basis.

    Appreciate this!

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Ok, so specifically what do you want help with here?

    I wouldn't "laugh" at anyone who makes the effort to have a go at what are quite complex Excel formulas (ok, maybe column I...), but I should let you know that column I does contain a bunch of #REF! errors - presumably you cut some sheets/cell references before posting?

    Anyway, like I said, if you could be specific about what exactly you want help with in here.

    Regards

  9. #9
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    It's a mess as it is hey!!!

    What I want to achieve: from the email address, tell me First Name, Company Name, Entity, Country. Also mark cells containing certain "bad" words to be removed.

    So 3 phases I suppose.

    1 Break the email address up into certain segments. i.e. Name (before the @), domain (PROPER after @), Country Suffix (bit after the last dot, i.e. .co.uk = ".uk"), Entity suffix, i.e. .ac, .gov after the @.
    2 Create lists to LOOKUP. As already done with the counties in sheet2.
    3 Formulas
    Countries: nearly there just need to make it look up after and including the last dot.
    First Name: need to make database and import to a list. Can return the same value as the SEARCH. Will this have alphabetical problems?
    Company name: To return the bit after the @ and before the next dot. Unless it contains certain words. i.e. Gmail, Hotmail, Yahoo.
    Entity: To search the bit after the @ and look for .ac, .gov etc.
    Unwanted emails: If the email contains for instance "unsubscribe" in the cell. Mark it so I can bin it.

    I would like to add all my lists like the country one to sheet2 so as and when I can easily add to it.

    Does this make sense?!

    Excited to get this working!

  10. #10
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Sorry - even more confused now!

    You seem to already have formulas for most of your desired extractions in there. Or are you suggesting that you actually want some sort of audit/improvement process carrying out on your existing set-up?

    Also, for example - just to take a more general look at what you're trying to achieve - once you've got your large database of names (by the way, is this to cover all names of all nationalities?!), how do you propose to make certain that the correct name from amongst many partial matches is identified? How do you know for sure which part of an address is an initial, which part a surname, a first name, a pseudonym, a joke, a mother's name, etc., etc., etc.?

    Don't get me wrong - I'm happy to help you with some specific formula concerns of yours (after all, that's what I've done so far - and the reason you came to the forum) but based on your last post, it would seem that you've got an extremely ambitious project outlined here, and one which, for the practical reasons I alluded to above, I don't see as being fully achievable, whatever the degree of refinement of formulas we manage to achieve.

    Having said that, if you can take each part step-by-step, and perhaps beginning a new thread for each separate query (the forum is quite insistent on that sort of thing, and it would make some sense here), then I'll see what I can do to help in terms of the formula work.

    Regards

  11. #11
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    TO SEND take 2.xlsxHiya, I have tidied up my mess and you will see on sheet2 my idea behind the lists.

    Things that do not work:

    1 I can't get the entity LOOKUP formula to respond.
    2 Names, please see highlighted in yellow as an example.
    3 Advice on how to search for the bad words formula.
    4 Company name - looks ok??

    Regarding, whether its a surname or not there is no way to really tell, but I would like it to return a best guess first name for instance, as per my list.

    I think I'm nearly there, thanks to you!! :D

  12. #12
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi,

    "I can't get the entity LOOKUP formula to respond."

    This formula currently references Sheet2!$H$4:$H$6 and Sheet2!$I$4:$I$6 - shouldn't those rows be from 3 to 5?

    "Names, please see highlighted in yellow as an example."

    But your list of names contains both a "Billy" and an "Andre"! This is precisely what I was talking about: for the e-mail address andrebilly.heroldttom, how can you tell a programme which is the first, and which the second name?

    I mean, as it is, it finds them both, though since Billy is alphabetically later, it returns that one. I'm not sure how you'd like to get over this, since if you tell it instead to take the alphatetically earlier, it wouldn't surprise me at all if sooner or later you came across an e-mail address of the form [surname][firstname].com and then you'd wish you'd kept it as it was!

    "Advice on how to search for the bad words formula."

    The only way to do this would be to have a definitive list of all words which you define as "bad".

    "Company name - looks ok??"

    Sure - nice formula.

    Regards

  13. #13
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Great.

    Regarding first name can I make it stick with the first name it finds. I know occasionally this will be wrong. So andrebilly@ would return Andre.

    Regarding bad words list, assuming it's now definitive as per sheet2 how do I create this? I assume in the same way as previous formulas?

    How do I pull the last info from a cell so I just get the last dot plus text? I.e. Pwc.co.za returns .za ? For my countries lookup I need this!

    Thanks again

  14. #14
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi,

    "Regarding first name can I make it stick with the first name it finds. I know occasionally this will be wrong. So andrebilly@ would return Andre."

    This is not so straightforward as you might think. What exactly do you mean by "first name it finds"? (On another point, are you happy with your result of "Stan" for "exceltestandrew"?)

    I assume that you actually want to change the process so that we search the e-mail address from left to right, increasing the length of the substring one letter at a time, until that matches one of the names in the list? Ok, but then what should the return be for, for example, [email protected]? Ann (her name may be Ann Abelfort)? Anna (Belfort)? Or Annabel (Fort)?

    I know which I'd take, but a programme can't make decisions like that! Basically, going left-to-right, we could use two feasible algorithms:

    1) Assume the first letter of the first name is the very first letter in the e-mail address and check strings of increasing length until a match is found, then stop. This would results in Ann for the above example.

    2) Assume the first letter of the first name is the very first letter in the e-mail address and check strings of all lengths (up to the "@" sign) and return the longest string which is a match. This would results in Annabel for the above example.

    "Regarding bad words list, assuming it's now definitive as per sheet2 how do I create this? I assume in the same way as previous formulas?"

    Yes.

    "How do I pull the last info from a cell so I just get the last dot plus text? I.e. Pwc.co.za returns .za ? For my countries lookup I need this!"

    This will give you the string after the last dot (without the dot):

    =TRIM(RIGHT(SUBSTITUTE(A1,".",REPT(" ",255)),255))

    though I'm not sure how you want to deal with cases like .co.za.edu.

    Regards

  15. #15
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi,

    though I'm not sure how you want to deal with cases like .co.za.edu

    That was a fake email, the .ac, .gov. and .edu representing the entity are in this format

    [email protected] / .ac.za and just .edu (no country representation) - so I'm quite happy with the last two letters replresenting the country. in the case of .edu, I can make "du" return a blank.

    First Names!

    Good points! I would like it to search the string from the left finding the longest word. Will this work with [email protected] - returning Alexander?

    Excited to put this all in place now! Just some fiddling to go!

    Thinking ahead, with my LOOKUP lists can I make the ranges longer than needed so I can add to the bottom, i.e. if a new country gets added. Then I just have to manually sort - right?

    When I paste my long list of emails into column A when this is ready do I just copy the formulas down, or is there an automated way to do it if the cell in row A is not blank? (prob just over complicating it!)

    Thanks so much! Looking forward to getting this sorted!

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    "Will this work with [email protected] - returning Alexander?"

    No. Since both my algorithms state: "Assume the first letter of the first name is the very first letter in the e-mail address", so it would look for the strings:

    "b", "ba", "bal", "bale", "balex", "balexa", "balexan", "balexand", "balexande", "balex", "balexander"

    and, from amongst those which match against your list, choose the longest.

    We could have the algorithm go through all strings of all lengths from all starting points, if you want, i.e. as well as the above, it would also then search for:

    "a", "al", "ale", "alex", ... ,"l", "le", "lex", "lexa", ..., "e", "ex", "exa", "exan", ... , "r"

    and then take the longest of those, but this is making things much more complicated, not to mention the fact that it would then potentially take a surname over a first name (since we are no longer restricting our search strings to beginning with the first letter of the e-mail address).

    I'm afraid you need to make a decision over one of the two algorithms I proposed (or offer an alternative that I haven't yet mentioned, of course) and accept the fact that, like I said earlier, it's simply never going to work in all cases. I'm afraid that you still just don't seem to grasp how near-impossible it is to know with any reasonable certainty which part of a given e-mail address is the first name. Not to mention the fact that no part of it may be the first name...

    Regards

  17. #17
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I totally understand your point. I'm trying to make the formula a best guess at the first name. As typical surnames are not in my LOOKUP it will only rarely return an incorrect first name. i.e. James or Stewart possibly being both.

    I'm happy to go with your proposal here;

    We could have the algorithm go through all strings of all lengths from all starting points, if you want, i.e. as well as the above, it would also then search for:

    "a", "al", "ale", "alex", ... ,"l", "le", "lex", "lexa", ..., "e", "ex", "exa", "exan", ... , "r"

    That would give me the best chance of getting the correct name. I know its not 100%!

    Cheers, nearly there ! :-)

  18. #18
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Also my countries are all " South Korea"(space before the first letter). How do I remove an initial space? And not all the spaces? Normally I would do a find and replace!

  19. #19
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    "Also my countries are all " South Korea"(space before the first letter). How do I remove an initial space? And not all the spaces? Normally I would do a find and replace!"

    That first "space" appears to be some sort of other spacing character, perhaps as the result of you importing the file from some other software? If you go into the word, highlight that portion (this spacing character) of the string only, copy, then exit.

    Now do a Find & Replace by pasting this character into the Find what: field and leaving the Replace with: field blanks. That should remove all these but leave "normal" space characters untouched.

    Re First Names, please test this array formula** in G2:

    =IFERROR(INDEX(Sheet2!$D$3:$D$1221,MATCH(MAX(IF(ISNUMBER(SEARCH(Sheet2!$D$3:$D$1221,B2)),LEN(Sheet2!$D$3:$D$1221))),IF(ISNUMBER(SEARCH(Sheet2!$D$3:$D$1221,B2)),LEN(Sheet2!$D$3:$D$1221)),0)),"")

    Copy down as required.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  20. #20
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    TO SEND take 3.xlsx

    Please see the attached, not working. Am I doing something wrong?

  21. #21
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Regarding the Company Name, the same process as on most doesnt really work.

    It needs to be =PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1))

    But !

    if it contains one of the words in my LOOKUP Sheet2! M3-M6. Then I want it to return X, in this case a blank. To remove words Hotmail, Gmail etc.

    Nearly there!

  22. #22
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Why have you changed the reference to cell B2 in my posted formula to A2?

    Regards

  23. #23
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I was playing trying to get it working. My bad, apologies. Works like a dream!

  24. #24
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I think once I sort the bit about the company name I am good to go.

    I can't thank you enough. Do I acknowledge this is resolved? Do you get an improved status or anything?

    Thanks so much

  25. #25
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    So for the Company Name, you want to keep the formula as it is, but add in a clause that returns an "X" if it contains one of the strings in Sheet2! M3-M6?

    Regards

  26. #26
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Exactly! Thanks

  27. #27
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Ok:

    =IF(ISNUMBER(MATCH(PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)),Sheet2!$M$3:$M$6,0)),"X",PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)))

    Regards

  28. #28
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I'm currently implementing all the formulas. Thanks so much for your help.

    You've been amazing, well that's a complete understatement!

  29. #29
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    You're welcome!

    Good luck with the project! And with deciphering those first names!

  30. #30
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I've removed pretty much all first names with less than 5 characters as it was too conflicting. My names LOOKUP list is now 3000 long!

    I've had to take out a few country codes such that conflicted too.

    I've been trying to find a list of spam/noreply words associated to email addresses. I just have to manually look for words at moment.

    As I've pulled 60,000 emails from Outlook I want to minimise hard bounce emails!

    Any extra ideas welcome

  31. #31
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    "Any extra ideas welcome"

    I hope you'll understand but with the utmost of respect I think I'm about done with this thread!

    Regards

  32. #32
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    I hadn't even started!!!

    Thanks so much.

    So how does this forum work? Can I recommend you or something?

    Cheers

  33. #33
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hahaha!! I'm sure!

    You can click on the Add Reputation star in the bottom-left if you really want.

  34. #34
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    1 last thing!

    Countries:

    =IFERROR(LOOKUP(100^100,SEARCH("*"&Sheet2!$A$2:$A$256&"*",K2),Sheet2!$B$2:$B$256),"Other")

    Works great except I was a bit naive, its not just the bit after the last dot I need. I found a problem as I had to remove a few conflicting countries. i.e. Burundi. The code is .bi however I had a lot of .biz's. So removed it.

    Can you tell me how to make it a rule where it looks for the last dot but only considers the last 2 digits.

    Cheers.

    I added reputation. Least I can do!

  35. #35
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Sorry this is prob the bit that needs adjusting

    =TRIM(RIGHT(SUBSTITUTE(A2,".",REPT(" ",255)),255))

  36. #36
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi again.

    Bit confused. Which formula are you actually using/wanting to use for the CC? Just extracting it from the Domain, as the TRIM(SUBSTITUTE... formula does, or using this LOOKUP(SEARCH... formula (which I didn't know you were considering for this field, to be honest)?

    If it's the former, are you saying that something ending in e.g. .blz should return lz?

    Regards

  37. #37
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Sorry!

    Basically I only want it to return values that are 2 digits in length. So I'm assuming a LEN/COUNT somewhere?!

    e.g.

    .uk returns uk
    .eg reyurns eg
    .com returns a blank

    all countries have 2 letters, so this should work?!

    Cheers

  38. #38
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Well, you could either adapt it to:

    =IF(LEN(TRIM(RIGHT(SUBSTITUTE(A2,".",REPT(" ",255)),255)))>2,"",TRIM(RIGHT(SUBSTITUTE(A2,".",REPT(" ",255)),255)))

    Or add an extra column and simply:

    =IF(LEN(D2)>2,"",D2)

    Regards

  39. #39
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    That's cracking. Sorry about the thread confusion. As it was an isolated request and I had already ticked "Add Reputation" I figured that was the practice.


    OK, so now my task perhaps does require a new thread!


    I want to clean data where there is already some information that I want to keep.

    i.e. I have an email address database with correct information but spread sporadically. i.e. First Name, Country etc my be missing. I want the values assigned to remain. But where there is no country I want it to have one.

    I want to run my formulas against the blanks.

    My thought process is to filter the blanks one by one by field. i.e. Country, filter blanks then manually copy my formula into the blanks. This is very labor intensive and prone to human error though!

    Is there a way I can dump a database over my current formulas but it only runs the formulas on blanks. Then returning a value where applicable? Or is this way out of Excels league?

    Cheers.

  40. #40
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Why not just have an extra column which runs the formula only if the entry adjacent to it is blank. e.g. IF(A2="",[formula],A2)?

    Regards

  41. #41
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    That'll prob work yeah.

    Can I make it return the value if there was one though. I suppose I would need to change each formula accordingly?

    i.e. If already a first name then put that value if not run the formula!

  42. #42
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    That's precisely what that formula does!

    Regards

  43. #43
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Nearly there now!!! You would have had this sorted in minutes I know! Trouble is with so many email addresses there are certain things that break my rules.

    i.e. [email protected]

    My formula currently returns the Company as za - ann.biger@"za".didata.com

    So I know this is a pain but can I have a rule that if certain text"." strings after an @ then return the bit after the next .

    So I want it to return didata as the Company !

    current formula is;

    =IF(ISNUMBER(MATCH(PROPER(LEFT(REPLACE(A4077,1,FIND("@",A4077),""),FIND(".",REPLACE(A4077,1,FIND("@",A4077),""))-1)),Sheet2!$L$2:$L$8,0)),"",PROPER(LEFT(REPLACE(A4077,1,FIND("@",A4077),""),FIND(".",REPLACE(A4077,1,FIND("@",A4077),""))-1)))

    I operate in the African market and so far have only come across "za" for South Africa which is relevent to this request.

    Should I have a further look up or can you put an further IF into the formula!

    Cheers

  44. #44
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    "So I know this is a pain but can I have a rule that if certain text"." strings after an @ then return the bit after the next ."

    Not sure I understand. You mean if there's more than one "dot" after the "@", apply this new rule? But what will this mean for [email protected], [email protected]?

    Or do you mean only if "za" is present after the "@" then apply this new rule? But then what do you mean by "certain text strings" (plural)?

    Regards

  45. #45
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hope you had a good weekend! Sorry for the delayed reply.

    Basically the main mistakes in my "Company Name" field were assigned to a handful of pre suffixes. For instance @za.pwc.com - @tz.ibm.com. There appear to be just a a few of these pre suffixes which refer to countries. So with those example I want the country to be assigned by the first two letters "za" and "tz" and the company to be the bit after the first.

    So to do this, can we do a new IF within the formula, so IF equals "za", "ae", "za", "tz", "eu" or "ts". Then it applies a different rule. Perhaps I may need to edit this list but I do not envisage it getting too long. Ideally it would look these differences up in a LOOKUP. So sheet2 could have.

    za - South Africa
    tz - Tanzania

    etc....


    For the company name as it is;

    =IF(ISNUMBER(MATCH(PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)),Sheet2!$L$2:$L$15,0)),"",PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)))

    Would I be really over complicating it by adding a lookup for certain company names. i.e. if pwc - return Price Waterhouse Coopers, uf - return University of the Free State. etc. . . .


    Cheers,


  46. #46
    Registered User
    Join Date
    02-05-2014
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hiya, did you have a chance to look at my last request?

    Thank you

  47. #47
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: SEARCH function for multiple variables - VLOOKUP?

    Hi,

    Sorry, but with all the other threads I deal with on this forum, and the fact that we're now on post #46 (!) with this one, I think it may well be time that you began a new thread.

    I would also suggest that you make your question in that new thread as simple as possible. For example, rather than post your existing formula:

    =IF(ISNUMBER(MATCH(PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)),Sheet2!$L$2:$L$15,0)),"",PROPER(LEFT(REPLACE(A2,1,FIND("@",A2),""),FIND(".",REPLACE(A2,1,FIND("@",A2),""))-1)))

    and ask for this to be adapted, I think it would be much wiser if you started with a simple example list of e-mail addresses and queried how it woud be possible to make the extraction at the relevant point depending on whether one or more of your search words was found.

    Once you have that formula, you'll then be able to either insert it into the above formula, or use it in an extra helper column in your sheet and then combine it with the existing formulas.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel Vlookup, multiple sheets and multiple variables
    By caninekopz in forum Excel General
    Replies: 3
    Last Post: 11-27-2013, 10:33 AM
  2. How can I use VLOOKUP to search within a table contains 4 variables
    By medo82006 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-21-2013, 04:11 PM
  3. [SOLVED] Multiple Sheet Search - Matching Variables
    By plasma33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2012, 06:02 AM
  4. Excel 2007 : Using variables in a vlookup function VBA
    By tschiman in forum Excel General
    Replies: 0
    Last Post: 02-10-2012, 05:14 PM
  5. ISTEXT or SEARCH function with 2 variables
    By mobycane in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-08-2010, 04:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1