+ Reply to Thread
Results 1 to 6 of 6

left to first or second comma

  1. #1
    Registered User
    Join Date
    01-05-2006
    Location
    Toronto, Ontario
    MS-Off Ver
    2007
    Posts
    38

    Smile left to first or second comma

    I was wondering if there is a way to do a logical operation like this.

    If a cell containg text has 2 comma delimiters, extract everything from the left of the second comma.

    or if the cell has on comma, extract everything to the left of the first comma.

    Any takers

    Thanks

    Dennis

    Thanks For your help everyone
    Last edited by terrysoper1973; 09-14-2011 at 03:19 AM.

  2. #2
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: left to first or second comma

    Please Login or Register  to view this content.
    This ony looks for zero, one, or two commas ...

  3. #3
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: left to first or second comma

    Sorry. Re-read your post. You say if it has on[e] comma, extract everything to the left of that comma. But if it has two commas, do you really want everythng FROM the second comma, or up to it? I did the latter, but it's easy to change if I know what the rule is.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: left to first or second comma

    Try:

    =LEFT(A1,FIND("^^",SUBSTITUTE(A1,",","^^",LEN(A1)-LEN(SUBSTITUTE(A1,",",""))))-1)

    this extracts from first char to just left of last comma.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  5. #5
    Registered User
    Join Date
    01-05-2006
    Location
    Toronto, Ontario
    MS-Off Ver
    2007
    Posts
    38

    Re: left to first or second comma

    It's somthing like this.

    2737 bakers street dufferin, Ontario
    2737, bakers street dufferin, ontario

    Where I want everything but ontario

    Thanks

    Terry

  6. #6
    Forum Contributor bentleybob's Avatar
    Join Date
    02-27-2009
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    644

    Re: left to first or second comma

    Then either solution works (although NBVCs does not address when there's no comma).

+ 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