+ Reply to Thread
Results 1 to 7 of 7

Extract phone number front block of text

Hybrid View

  1. #1
    Registered User
    Join Date
    10-07-2004
    Posts
    5

    Extract phone number front block of text

    I have a webpage that lists business names, address, phone number, etc. There is no definite pattern to how they entered the text. What I'd like to do is something like....

    Search cell A1 for "-", return the 3 characters to the left of the "-".

    In the next column do...

    Search cell A1 for "-", return the 4 characters to the right of the "-".

    Then I can concatenate the two and add in the area code.

    TIA guys/gals.


    PS. I tried searching but didn't know exactly what to search for and didn't get very far.

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    HI, Tech. Where will you get the Area Code that you will 'add in'?

    Also, how will you handle single cell entries that also use the hyphen in a business name (e.g. Allis-Chalmers) or a city (e.g. Wilkes-Barre, PA) or a 9 digit ZIP code (e.g. 90210-1234)?

    Things to ponder....

    Bruce
    Last edited by swatsp0p; 08-04-2005 at 10:03 AM.
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Registered User
    Join Date
    10-07-2004
    Posts
    5
    The area code is the same for every number (in this case).

  4. #4
    Michael
    Guest

    RE: Extract phone number front block of text

    For the left three numbers, =MID(A1,(SEARCH("-",A1)-3),3). For the right
    four numbers, =MID(A1,(SEARCH("-",A1)+1),4). If these formula are in B1 and
    C1, to combine the numbers with the area code, "925 "&B1&"-"&C1. HTH
    --
    Sincerely, Michael Colvin


    "Tech" wrote:

    >
    > I have a webpage that lists business names, address, phone number, etc.
    > There is no definite pattern to how they entered the text. What I'd
    > like to do is something like....
    >
    > -Search cell A1 for "-", return the 3 characters to the left of the
    > "-".-
    >
    > In the next column do...
    >
    > -Search cell A1 for "-", return the 4 characters to the right of the
    > "-".-
    >
    > Then I can concatenate the two and add in the area code.
    >
    > TIA guys/gals.
    >
    >
    > PS. I tried searching but didn't know exactly what to search for and
    > didn't get very far.
    >
    >
    > --
    > Tech
    > ------------------------------------------------------------------------
    > Tech's Profile: http://www.excelforum.com/member.php...o&userid=15107
    > View this thread: http://www.excelforum.com/showthread...hreadid=392890
    >
    >


  5. #5
    Registered User
    Join Date
    10-07-2004
    Posts
    5
    Worked great! Thanks for your help!

  6. #6
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Of course, you could combine Michael's formula into one cell, as such:

    in B1 ="925 "&MID(A1,(SEARCH("-",A1)-3),3)&"-"&MID(A1,(SEARCH("-",A1)+1),4)

    The result would be, e.g.

    952 123-4567

    Good Luck

    Bruce

  7. #7
    Michael
    Guest

    Re: Extract phone number front block of text

    Glad it worked. Thanks for the feedback.
    --
    Sincerely, Michael Colvin


    "Tech" wrote:

    >
    > Worked great! Thanks for your help!
    >
    >
    > --
    > Tech
    > ------------------------------------------------------------------------
    > Tech's Profile: http://www.excelforum.com/member.php...o&userid=15107
    > View this thread: http://www.excelforum.com/showthread...hreadid=392890
    >
    >


+ 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