+ Reply to Thread
Results 1 to 5 of 5

Nesting If/Then and Vlookup

  1. #1
    Registered User
    Join Date
    06-30-2013
    Location
    KC,KS
    MS-Off Ver
    Excel 2010
    Posts
    2

    Smile Nesting If/Then and Vlookup

    For example:

    column b2 has list of types of supplies.
    If b2 says "pencils" I want it to lookup the ID number in Column c2 and look up a price on sheet 1 column 2.
    If b2 says anything besides pencils i want it to look up the ID number in column c2 in sheet 2 column 49

    I've done this before but for some reason i can't it to work and i've tweaked the formula so many times I'm starting to confuse myself.

    My latest attempt :

    =if($b2="pencils",(vlookup,$c2,'Sheet 1'!$A:$AP,2)if($b2<>"pencils",(vlookup,$c2,'Sheet 2'!$A:$FJ,49))

    Thanks In advance for any help.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nesting If/Then and Vlookup

    you have only two condition..

    =if($B2="pencils",vlookup(C2,$A:$B,2),vlookup(C2,$A:$AF,49))
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Nesting If/Then and Vlookup

    =vlookup(C2,$A:$AF,if($B2="pencils",2,49))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

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

    Re: Nesting If/Then and Vlookup

    hmmmm. i thought OP's VLOOKUP are in 2 different sheets? Column A:AF also does not have 49 columns.

    @JoJoGrl:
    i suggest you upload a sample Excel file & show us 2 scenarios of answers. 1 is when B2 is "Pencil". tell us which cell should be the result. another is when B2 is not "Pencial". tell us what should be the result. i'm guessing:
    =IF($B2="pencils",VLOOKUP($C2,'Sheet 1'!$A:$B,2),VLOOKUP($C2,'Sheet 2'!$A:$AW,49))

    or:
    =IF($B2="pencils",VLOOKUP($C2,'Sheet 1'!$A:$B,2,0),VLOOKUP($C2,'Sheet 2'!$A:$AW,49,0))

    i think we are confused by the portion in red:
    =if($b2="pencils",(vlookup,$c2,'Sheet 1'!$A:$AP,2)if($b2<>"pencils",(vlookup,$c2,'Sheet 2'!$A:$FJ,49))
    - why range up A:AP when you only need the 2nd column?
    - why range up A:FJ when you only need the 49th column?
    - is the ID number for Sheet 1 & 2 both in column A?

    to attach a file, Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    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

  5. #5
    Registered User
    Join Date
    06-30-2013
    Location
    KC,KS
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Nesting If/Then and Vlookup

    Hello Everyone! Thanks so much for the feedback and I'm so sorry its been so long since I've checked in. I've been extremely ill and this is the first time I've been able to check in.

    I'm pretty sure the first response is exactly what I used the first time I tried it....but I don't have access to try, verify, or post examples right now. My first chance to do so I will. I just didn't want everyone to think I didn't appreciate them.

    Thanks! I will follow up.

+ 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