+ Reply to Thread
Results 1 to 16 of 16

Extracting Specific Word Using Mid/Find

Hybrid View

Stonesteel15 Extracting Specific Word... 05-13-2012, 03:38 AM
canapone Re: Extracting Specific Word... 05-13-2012, 04:39 AM
Stonesteel15 Re: Extracting Specific Word... 05-13-2012, 04:58 AM
canapone Re: Extracting Specific Word... 05-13-2012, 05:09 AM
Stonesteel15 Re: Extracting Specific Word... 05-13-2012, 05:24 AM
canapone Re: Extracting Specific Word... 05-13-2012, 05:35 AM
Stonesteel15 Re: Extracting Specific Word... 05-13-2012, 05:45 AM
Stonesteel15 Re: Extracting Specific Word... 05-13-2012, 07:16 AM
canapone Re: Extracting Specific Word... 05-13-2012, 08:09 AM
Stonesteel15 Re: Extracting Specific Word... 05-13-2012, 10:18 PM
Stonesteel15 Re: Extracting Specific Word... 05-15-2012, 12:09 AM
Stonesteel15 Re: Extracting Specific Word... 05-16-2012, 04:42 AM
canapone Re: Extracting Specific Word... 05-16-2012, 05:05 AM
Stonesteel15 Re: Extracting Specific Word... 05-17-2012, 09:11 PM
canapone Re: Extracting Specific Word... 05-20-2012, 02:08 AM
Stonesteel15 Re: Extracting Specific Word... 05-21-2012, 10:11 PM
  1. #1
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Extracting Specific Word Using Mid/Find

    Greetings!

    I would like to ask what formula should I use to extract specific word by referencing a word after the word I want to extract. given with this example.

    Billing Address.xlsx

    the reference is the word "PHILIPPINES"
    then I wanted to extract the province for example "METRO MANILA" in Column C, which is the word before the reference "PHILIPPINES"
    then I wanted to extract the city/town for example "TAGUIG" in Column B, which is the word before the province.

    by using the function MID and FIND how should I create a formula to extract those words. Appreciate your feedback, tnx.
    "Consummatum Est"

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    you could write a list of provinces in - for example- G3:G50

    In C3:

    =INDEX($G$3:$G$50,MATCH(1,SEARCH("*"&$G$3:$G$50&"*",A3),0))
    or as Excel 2007 user something like:

    =IFERROR(INDEX($G$3:$G$50,MATCH(1,SEARCH("*"&$G$3:$G$50&"*",A3),0)),"No match")


    The formula must be confirmed with control+shift+enter and then copied down.

    Just for sharing a first option

    Regards
    Attached Files Attached Files
    Last edited by canapone; 05-13-2012 at 04:46 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    Hi Canapone, thank you for the suggestion, your approach may be applicable to the province column only, since in my database I only had 92 provinces in total, but doing it in column of city/town, it may respond too long since there are total of 900 cities in the database. Is there any other option to extract the town/city?

  4. #4
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    are cities one word only?

    Example not "CAPE TOWN" or "LAS VEGAS".

    Regards


    EDIT: sorry I had not seen QUEZON CITY.

    In this case the only easy option is -again- matching a list of cities.

    Waiting for better solutions.

    Regards
    Last edited by canapone; 05-13-2012 at 05:24 AM.

  5. #5
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    Unfortunately, it's not, there are some cities with three words on it.

    by the way, can you check what's wrong with the formula I used, the index is just in another sheet, and all of its results are "No Match"

    AddFin 1.0.xlsm

    this is the original workbook I am working for.

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    i'll take a look at the formula in the afternoon, I'm back in two hours.

    Meanwhile I hope you gett better solutions.

    See you later

  7. #7
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    Ok, I'll be waiting for it.

    at this time of need, your approach may be the better solution to work for.

  8. #8
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    hmm, I think I got it now, looking thoroughly from the formula you've given, I made the formula by mistake, it is now working and resulting to a right output.

    {=IFERROR(INDEX(ProTown!A$2:A$83,MATCH(1,SEARCH("*"&ProTown!A$2:A$83&"*",I3),0)),"No match")}

  9. #9
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    exactly.
    You have to complete the list of provinces to avoid "no match"'s, if you cannot download from internet a list of the cities and use the same formula, you could prepare a smaller list of cities composed by two or more strings (see the example attached in column B) and use again IFERROR

    =IFERROR(INDEX(ProTown!$B$2:B$83,MATCH(1,SEARCH("*"&ProTown!$B$2:$B$83&"*"I3),0)),TRIM(RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(I3," "&UPPER(K3),"")," "&L3,"")," "&"PHILIPPINES","")," ",REPT(" ",100)),100)))
    Again control+shift+enter

    I'm sure there are better and more elegant solutions.

    Regards
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    hi Canapone, thank you for your help. For the meantime I will be using your formula. It's helping me in my project anyway.

    If you wouldn't mind, do you know how to use this formula in VBA? I just wanted to add this to the code, I am inserting this to the last part. where,

    ActiveCell.Offset(0, 8).value = {=IFERROR(INDEX(ProTown!A$2:A$83,MATCH(1,SEARCH("*"&ProTown!A$2:A$83&"*",I3),0)),"No match")}

    I wanted to put the output of the formula to the specified cell range not to put the formula itself.

  11. #11
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    I got it, I am using this formula now inserted in a vba code.

    ActiveCell.Value = Evaluate("IFERROR(INDEX(ProTown!A$2:A$83,MATCH(1,SEARCH(""*""&ProTown!A$2:A$83&""*"",OFFSET(" & ActiveCell.Address(0, 0) & ",0, -2)),0)),""No match"")")
    Thank you for your help Canapone.

  12. #12
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    Hi Canapone,
    can you identify what is the cause why it always giving result of "No Match" in this formula? I think the formula is correct but I don't know why there's no match.

    AddFin 1.0.xlsm

  13. #13
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    you should create a list of cities in a single column (B2:B823) and in the INDEX and in SEARCH change B2:E107 in B2:B823.



    The formula should work.

    Regards

  14. #14
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    hi Canapone, thank you for your advise, unfortunately upon observing, this formula cannot be used for city, since there are cities that are the same as province, it will give a result which searches for the province first, is there a way that the match/search will start from the left so that it will find first the city before the province? let's say for example, i have here the address:

    ZONE 7 SITIO KAUNLARAN WESTERN BICUTAN WESTERN TAGUIG METRO MANILA PHILIPPINES 1630

    what I need is the search will start from the left, so that it could find first the city "TAGUIG" instead of finding "MANILA", the result of the formula in this address is "MANILA" since it is also included in the list of cities.

  15. #15
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Extracting Specific Word Using Mid/Find

    Hi,

    I don't know if it's the best solution: try to move at the bottom of the list of cities the provinces/cities in order to create a sort of hiearchy different from the natural alphabetical order.

    Hope it's a little help

    Regards
    Last edited by canapone; 05-20-2012 at 03:03 AM.

  16. #16
    Registered User
    Join Date
    03-21-2012
    Location
    Metro Manila, Phiippines
    MS-Off Ver
    Office 2007
    Posts
    77

    Re: Extracting Specific Word Using Mid/Find

    Hi Canapone, ok I'll try your suggestion. thank you for the suggestion.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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