+ Reply to Thread
Results 1 to 12 of 12

Find - Replace help help

  1. #1
    Registered User
    Join Date
    02-24-2006
    Posts
    9

    Find - Replace help help

    so vlookup needs an exact search to look up from:

    if I have a value = "aaa-US"
    but I am trying to look up a value for "aaa"
    I would have to systematically strip off the "-US"
    I know I can do a find "-US" or crtl F
    but any ideas on how I can create a formlula so I would have
    Column A Column B
    aaa-US aaa

    Thanks D

  2. #2
    Forum Contributor kraljb's Avatar
    Join Date
    05-26-2004
    Location
    Illinois
    MS-Off Ver
    2007 (recent change)
    Posts
    256
    =left(A1,len(A1)-3)

    The 3 being the number of Characters in "-US"

  3. #3
    CLR
    Guest

    RE: Find - Replace help help

    In B1 put

    =LEFT(A1,3)

    Vaya con Dios,
    Chuck, CABGx3



    "edmos1" wrote:

    >
    > so vlookup needs an exact search to look up from:
    >
    > if I have a value = "aaa-US"
    > but I am trying to look up a value for "aaa"
    > I would have to systematically strip off the "-US"
    > I know I can do a find "-US" or crtl F
    > but any ideas on how I can create a formlula so I would have
    > Column A Column B
    > aaa-US aaa
    >
    > Thanks D
    >
    >
    > --
    > edmos1
    > ------------------------------------------------------------------------
    > edmos1's Profile: http://www.excelforum.com/member.php...o&userid=31903
    > View this thread: http://www.excelforum.com/showthread...hreadid=516304
    >
    >


  4. #4
    Pete_UK
    Guest

    Re: Find - Replace help help

    if you always want to take the right hand 3 characters away, then this
    formula will do it in B1:

    =LEFT(A1,LEN(A1)-3)

    Then copy the formula down. Hope this helps.

    Pete


  5. #5
    Registered User
    Join Date
    02-24-2006
    Posts
    9
    What if all my data does not have the "-US"
    if I have
    aaa-US
    bbb-ME
    ccc

    I would want to display
    aaa
    bbb
    ccc

    any thoughts?

  6. #6
    Registered User
    Join Date
    02-24-2006
    Posts
    9
    What if all my data does not have the "-US"
    if I have
    aaa-US
    bbb-ME
    ccc

    I would want to display
    aaa
    bbb
    ccc

    any thoughts?

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996
    Try this:

    For text in A1

    B1: =IF(COUNTIF(A1,"*-*"),LEFT(A1,FIND("-",A1)-1),A1)

    If the text in A1 contains a dash (-), the formula takes the characters to the left of the dash. Otherwise, it takes all of the text.

    Does that help?

    Regards,
    Ron

  8. #8
    Niek Otten
    Guest

    Re: Find - Replace help help

    =IF(ISERROR(FIND("-",A1)),A1,LEFT(A1,FIND("-",A1)-1))

    --
    Kind regards,

    Niek Otten

    "edmos1" <[email protected]> wrote in
    message news:[email protected]...
    >
    > What if all my data does not have the "-US"
    > if I have
    > aaa-US
    > bbb-ME
    > ccc
    >
    > I would want to display
    > aaa
    > bbb
    > ccc
    >
    > any thoughts?
    >
    >
    > --
    > edmos1
    > ------------------------------------------------------------------------
    > edmos1's Profile:
    > http://www.excelforum.com/member.php...o&userid=31903
    > View this thread: http://www.excelforum.com/showthread...hreadid=516304
    >




  9. #9
    Pete_UK
    Guest

    Re: Find - Replace help help

    If you always want the first 3 characters from the left, then the
    formula that Chuck gave you will do this, i.e.:

    =LEFT(A1,3)

    Hope this helps.

    Pete


  10. #10
    Registered User
    Join Date
    02-24-2006
    Posts
    9
    hmmmm ok

    how about if it was aaa-41-US

    I would like to find aaa-41

    I have played around with a nested IF(replace) statement, but I have to know the placement

    could I create a IF (find (replace) or am I over confusing this?

    thanks
    D

  11. #11
    Registered User
    Join Date
    02-24-2006
    Posts
    9
    Thank Niek,
    I modified yours a bit,

    =IF(ISERROR(FIND("US",A1)),A1,LEFT(A1,FIND("US",A1)-2))

    seems to work perfectly

    I hav not used the iserror to much, looks like I need to brush off my excel skills a bit

    thank you all
    D

  12. #12
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996
    Ok...I think we can accomodate that:

    For text in A1 that may, or may not, contain dashes.

    This formula returns all of the characters to the left of the last instance of a dash:
    B1: =IF(COUNTIF(A1,"*-*"),LEFT(A1,LOOKUP(LEN(A1),FIND("-",A1,ROW(INDEX($A:$A,1,1):INDEX($A:$A,LEN(A1),1))))-1),A1)


    Does that do what you want?

    Regards,
    Ron

+ 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