+ Reply to Thread
Results 1 to 3 of 3

Vlookup with three variables

  1. #1
    Registered User
    Join Date
    02-17-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    2013
    Posts
    8

    Vlookup with three variables

    I have another complex (in my mind) Excel formula that I can't figure out.

    I first need to do a validation on one column (A) trying to validate if the "CAAA" option was selected...if it was, I need to multiply a VLookup value, multiply it by an exchange rate, and then lastly multiply it by another variable. IF anything other than CAAA is selected in Col A, I simply want to multiple the VLookup value by a separate variable.

    My formula is:
    =IFERROR(IF(A3="CAAA",VLOOKUP(B3,Table1,3,))*Setup!$B$10,0)*IF(C3=1,Setup!$G$2,IF(C3=2,Setup!$G$3,IF(C3=3,Setup!$G$4,VLOOKUP(B3,Table1,2,))*IF(C3=1,Setup!$F$2,IF(C3=2,Setup!$F$3,IF(C3=3,Setup!$F$4)))))

    I know I am running into the issue with VLookup only being able to consider one value, but I'm not sure what other command to use in it's place...or how else to accomplish my task.

    I have attached a sample of the file I am working on, which partially works...If CAAA is selected in Col A, the formula successfully runs as long as a value or 1 or 2 is selected for Col C (if a value of three is entered, there is an improper calculation made (probably because a new VLookup follows this option. IF anything other than CAAA is selected in Col A, the formula returns a "0" (I'm assuming a result of error checking).

    Any help would be appreciated.
    Thanks,
    Bill
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,907

    Re: Vlookup with three variables

    Try:

    =IF(A3="CAAA",VLOOKUP(B3,Table1,3,0)*Setup!$B$10*VLOOKUP(C3,Setup!$E$2:$G$4,3,0),
    VLOOKUP(B3,Table1,2,0)*VLOOKUP(C3,Setup!$E$2:$G$4,2,0))

    Or:

    =VLOOKUP(B3,Table1,IF(A3="CAAA",3,2),0)*VLOOKUP(C3,Setup!$E$2:$G$4,IF(A3="CAAA",3,2),0)*IF(A3="CAAA",Setup!$B$10,1)

  3. #3
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Vlookup with three variables

    IF anything other than CAAA is selected in Col A, the formula returns a "0"
    Since the formula leads with IF(A3="CAAA",VLOOKUP(B3,Table1,3,))* and there is no output specified for if FALSE that part of the formula defaults to a logical FALSE.

    If you are not aware of it applying math operators to TRUE/FALSE coerces those into their underlying values 1/0.

    Since 0 times any number always = 0 as long as A3 does not equal "CAAA" that part of the formula will always cause the rest of the formula to return 0.

    Has this helped so far?
    Dave

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Vlookup using variables
    By forrestgump1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-16-2016, 04:48 PM
  2. [SOLVED] vlookup with a few variables
    By kafarrell in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-28-2016, 04:01 PM
  3. [SOLVED] vlookup with variables
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2015, 09:26 AM
  4. Vlookup with 2 variables
    By Armitage2k in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-21-2014, 03:13 AM
  5. vlookup against various variables
    By papah73 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-25-2014, 06:36 AM
  6. [SOLVED] Vlookup two variables
    By PERE in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-28-2013, 06:36 AM
  7. [SOLVED] Can I identify variables using VLOOKUP, and then pass variable to another VLOOKUP?
    By Jeff C in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-05-2012, 05:54 PM

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