+ Reply to Thread
Results 1 to 8 of 8

need help with an if statement

  1. #1
    Registered User
    Join Date
    02-03-2009
    Location
    Upstate New York
    MS-Off Ver
    Excel 2003
    Posts
    31

    need help with an if statement

    cell g36 contains a "reference #"

    "reference number" contains 2 letters folloed by 8 digits

    for example cv09050102 or hd09050549 or gm09110201

    i need a if statement that will display in diiferent cell a name based my reference #

    all cv will be "Chris V"
    hd = Harley Davidson
    gm = George Michael
    Last edited by Ceeseven; 05-15-2009 at 01:49 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: need help with an if statement

    A worksheet formula to accomplish this is simply:

    =LOOKUP(LEFT(G36,2),{"cv","gm","hd"},{"Chris V","George Michael","Harley Davidson"})

    Notice in the two arrays, the first array HAS to be sorted properly.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: need help with an if statement

    U can use IF function, but your function'll be too long, depending on the amount of first two digits. I mean now u have three: cv… hd… gm…
    But tomorrow there can appear mn.. Df.. and so on.

    So I advise u to tcreate small table elsewhere and using simple VLOOKUP show what u want.


    see attachment
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    02-03-2009
    Location
    Upstate New York
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: need help with an if statement

    awesome thanks

    gonna try it right away!!!!!!

  5. #5
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: need help with an if statement

    =vlookup(left(a1,2),$h$1:$i$3,2,0)

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: need help with an if statement

    Your post does not comply with Rule 5 of our Forum RULES. We have Seven question forums: Miscellaneous, General, Programming, Worksheet Functions, Charting, Excel 2007 Help and New Users. Please choose the appropriate forum, and post your question in ONLY one forum.

    Moved to Functions Forum
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: need help with an if statement

    If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED].




    (Also, use the "scales" icon in our posts to leave Feedback, it is appreciated)

  8. #8
    Registered User
    Join Date
    02-03-2009
    Location
    Upstate New York
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: need help with an if statement

    Quote Originally Posted by ContaminatedWitExcel View Post
    =vlookup(left(a1,2),$h$1:$i$3,2,0)
    perfect thanks, i have 9 =)

+ 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