+ Reply to Thread
Results 1 to 6 of 6

How to search and extract specific words from an Excel worksheet ?

  1. #1
    Registered User
    Join Date
    10-24-2008
    Location
    Iasi
    Posts
    3

    How to search and extract specific words from an Excel worksheet ?

    Let's say i have in an A1...A800 column the names of 800 persons and the cities they live in, like:
    A
    1 John Connor Chicago
    2 Mary Alice, New York
    3 Mark New York Smith
    4 Washington, David Pitt
    5 Salt Lake City Andrew Barrymore

    I want to extract, in the B1...B800 column the city they live in, like:

    B
    1 Chicago
    2 New York
    3 New York
    4 Washington
    5 Salt Lake City

    Can anyone know how to do that ? The A1...A800 column is very deorganised , sometimes i have commas after the names, sometimes the city name is in front of the person name, sometimes after or in the middle. Thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2008
    Location
    singapore
    Posts
    626
    I think It's impossible with the original deorganised data.
    You need to manually organise it first.

    Then you can use the text functions, eg, Right(), Left(), Mid()
    I need your support to add reputations if my solution works.


  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524
    VBA could work for this
    Create a list of the cities, the macro will search the list and extract the city from the strings if they are there. Spelling is a factor of course.
    Look at the example, enable macros when opening the workbook.
    Click the button to extract the cities from the list.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-24-2008
    Location
    Iasi
    Posts
    3
    Quote Originally Posted by davesexcel View Post
    VBA could work for this
    Create a list of the cities, the macro will search the list and extract the city from the strings if they are there. Spelling is a factor of course.
    Look at the example, enable macros when opening the workbook.
    Click the button to extract the cities from the list.
    Really thanks for the code. It works perfectlly.
    But, if a city is not found in the cities list i will obtain an empty row. Can i obtain in that row a text like "No city found" with red color. Then i can complete the cities list in case the person is from a city which i don't have in my city list. Also, can i have the cities names (B column) in a specified column (let's say G column, i understand that if i change the offset from 1 to.. n.. i will obtain the value in the n column) ? I want also to obtain in the A column only the person name (or other column), without the name of the city. Thanks again!
    Last edited by newbr33d; 10-25-2008 at 07:53 AM.

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Find Wild Cards From List

    Give this a go,
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-24-2008
    Location
    Iasi
    Posts
    3
    Quote Originally Posted by davesexcel View Post
    Give this a go,
    Really thanks, dear Dave! I saved a lot of time with your help. I hope it will be usefull to others members too. Thanks again!

+ 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