+ Reply to Thread
Results 1 to 5 of 5

Return value when word begins inbetween two letters

  1. #1
    Registered User
    Join Date
    06-14-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Return value when word begins inbetween two letters

    Hi,

    I have a list of accounts in column B. I want to add attach a value to column A based on the letter column B begins with. So:

    Accounts beginning with all letters between A & F I want column A to return "Bob".
    Accounts beginning with all letters between G & O I want column A to return "Tom".
    Accounts beginning with all letters between P & Z I want column A to return "Harry".

    I also want accounts beginning with numbers, to say "Bob" as well

    What is the best way of doing this?

    Thanks

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Return value when word begins inbetween two letters

    hi se15, welcome to the forum. try:
    =LOOKUP(CODE(UPPER(LEFT(B1))),{48,71,80},{"Bob","Tom","Harry"})

    each numbers & alphabets have a code number, so 48-70 is actually 0-9 & from A-F, 71-79 is G-O, and so on

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Return value when word begins inbetween two letters

    try
    =IF(OR(LEFT(B1)={"g","o"}),"tom",IF(OR(LEFT(B1)={"p","z"}),"harry","bob"))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    06-14-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Return value when word begins inbetween two letters

    That's great, thanks guy, works perfectly

  5. #5
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Return value when word begins inbetween two letters

    =INDEX({"Bob","Tom","Harry"},MATCH(LEFT(B1),{"A","G","P"}))

+ 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