+ Reply to Thread
Results 1 to 6 of 6

truncating data before hyphen

  1. #1
    Registered User
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 20011 for Mac
    Posts
    5

    truncating data before hyphen

    Hi,

    I was an expert Lotus user! Which belies my rustiness and age. I have rudimentary Excel skills--understand formulas but have never been able to get a macro to work! My version of Excel is 2011 for Mac. I don't think the Mac version is relevant here. My problem:

    I have around 1000 cells that have a web address then an email address separated by a space then a hyphen then another space. The problem is that there aren't a consistent no. of characters in either the web address or the email. If there were I think I could use the Left function. I only want the email address so it's a matter of getting rid of everything before the hyphen and the space following space. Note: these are not live links in the spreadsheet or here. Thanks!!!!

    Examples:

    www.eeginfo.com*- [email protected]
    www.alaskaneurofeedback.com*- [email protected]
    www.affordablecounselingsolutions.com*- [email protected]

  2. #2
    Registered User
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 20011 for Mac
    Posts
    5

    Re: truncating data before hyphen

    I'm sorry--I made a typo. it should be "it's a matter of getting rid of everything before the hyphen and the space following the hyphen."

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: truncating data before hyphen

    With your first value in A1...

    =MID(A1,FIND("-",A1)+2,LEN(A1))

    ...copied down
    HTH
    Regards, Jeff

  4. #4
    Registered User
    Join Date
    10-25-2012
    Location
    United States
    MS-Off Ver
    Excel 20011 for Mac
    Posts
    5

    Re: truncating data before hyphen

    It worked!! (by putting the formula in B1.)

    Jeff-An additional favor: would you mind explaining the syntax? I think it will help me learn how to work with other formulae. As far as I can get--"In the middle of the contents of A1 find a hyphen, then move 2 to the right then LEN. Why do I use LENin this case, and do I have the rest right?

    Thanks!

  5. #5
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: truncating data before hyphen

    The MID function has three arguments.

    =MID(text,start_num,num_chars)

    The first argument is easy, what cell are you evaluating, and in this case, A1.

    A1 = www_eeginfo.com* - sjacobs_knology.net

    The next argument looks for a place to start. We use the "-" as the delimiter and then add two to establish our start number,

    =MID("www_eeginfo.com* - sjacobs_knology.net",19,LEN(A1))

    Finally, we use the Len(A1) to return the original length of the text to ensure the function stretches out enough numbers to capture the portion we are looking for. I use the Len just because it's what I learned, but some people will replace it with a big number such as 255. There may be other approaches, but as you testified, this works for you.

    These both do the same job:
    =MID(A1,FIND("-",A1)+2,LEN(A1))
    =MID(A1,FIND("-",A1)+2,255)

    In the end it all evaluates too...

    =MID("www_eeginfo.com* - sjacobs_knology.net",19,37)

    A great way to see what a formula is doing is to use the Evaluate Function.

    I know nothing about a MAC so not sure how to find this feature on a MAC.
    Last edited by jeffreybrown; 10-25-2012 at 06:31 PM.

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: truncating data before hyphen

    You are very welcome and thanks for the feedback

    -------------------------------------------------------------------------------------

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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