+ Reply to Thread
Results 1 to 19 of 19

Vlookup

Hybrid View

MattFD Vlookup 12-02-2016, 02:25 PM
Sam Capricci Re: Vlookup 12-02-2016, 02:30 PM
TMS Re: Vlookup 12-02-2016, 02:33 PM
MattFD Re: Vlookup 12-02-2016, 02:43 PM
MattFD Re: Vlookup 12-02-2016, 02:35 PM
Sam Capricci Re: Vlookup 12-02-2016, 02:54 PM
TMS Re: Vlookup 12-02-2016, 03:09 PM
MattFD Re: Vlookup 12-02-2016, 03:13 PM
TMS Re: Vlookup 12-02-2016, 03:28 PM
TMS Re: Vlookup 12-02-2016, 03:25 PM
Sam Capricci Re: Vlookup 12-02-2016, 03:29 PM
MattFD Re: Vlookup 12-02-2016, 03:33 PM
Sam Capricci Re: Vlookup 12-02-2016, 03:39 PM
Sam Capricci Re: Vlookup 12-02-2016, 03:52 PM
MattFD Re: Vlookup 12-02-2016, 04:01 PM
Sam Capricci Re: Vlookup 12-02-2016, 04:19 PM
MattFD Re: Vlookup 12-02-2016, 04:23 PM
Sam Capricci Re: Vlookup 12-02-2016, 04:30 PM
TMS Re: Vlookup 12-02-2016, 04:40 PM
  1. #1
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Vlookup

    Hi, is it possible to use a variable Index value in a VLOOKUP formula based on the value of a cell? Something like this: =VLOOKUP(10251, A1:B6, X1, FALSE) where cell X1 is defined by a formula like: =if(A1="true"(B1="false"(C1="4x6", then "x")

    Thanks, I'm pretty much a novice here, but am looking to create a quote sheet for mailing pieces that have some variable data to account for.

    Thanks!

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    you can use a vlookup where you have another formula in X1 but the value location in X1 is where in a vlookup formula that you are telling the formula how far to go. So if you are referencing A1:B6 you would typically see either a 2 in X1 or a 2 where X1 is in your formula. If you have true or false or 4x6 in X1 that will not tell the formula how far over to go to find the value in the lookup referenced A1:B6. Does that make sense?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Vlookup

    In your VLOOKUP, you are searching for 10251 in column A (A1:A6) and returning a matching value. In this instance, the matching value can only really be in column B ... though you could return the search value from column A. X1 would determine which column to return from the matrix so, in this instance, I don't think it will do what you want.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Thanks for replying! Okay, so it appears that the Index value is hard coded into the formula and can't be a variable.

  5. #5
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Thanks for replying! I think it makes sense. I should have looked at my example better. The table reference A1:B6 in my example is arbitrary. In my actual reference table, I have 12 columns, so my X1 cell value would be 1-12 depending on the 3 variables in A1, B1, C1.

    So, my hope was that the Index value in the VLOOKUP formlula, could be based on the value represented in cell X1.

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    I'm not sure I understand your comment in post #5. So going by what you wrote in post #4 if you have 12 columns of data and they begin in column A that means they go over to column L. If in cell X1 you have an if formula that returns either what is in A1 or B1 or C1 depending on values, say what it returns from A1 is a 4, from B1 it would be a 6 or from C1 it would be a 12, then if your vlookup formula is this =VLOOKUP(10251,A1:L6000,X1,FALSE) and your value in X1 is 4 when the formula finds 10251 in column A between rows 1 and 6000, it will go over to the 4th column (column D in this instance) and return the value there. If it is a 6 it'll return the value in column F, etc.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Vlookup

    Yes, it can be a variable but, logically, it would need to return a value between 2 and 12. Your IF example (which doesn't work syntactically) would return a text value of 4x6 or x. Neither of those values would work as a (numeric) column Index.

  8. #8
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Thank you guys! Sorry for my struggle articulating my questions.

    Awesome, TMS--how do I format the Index value within the vlookup formula to accomplish that?

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Vlookup

    Without using X1:
    Formula: copy to clipboard
    =VLOOKUP(10251, A1:L1000, IF(AND(A1="true", B1="false", C1="4x6"), D1*E1, F1*G1), FALSE)


    Which makes interesting reading as you are looking for a numeric value in column A but then A1 is shown as potentially = "true".

    Getting confused now ...

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Vlookup

    where cell X1 is defined by a formula like: =if(A1="true"(B1="false"(C1="4x6", then "x")
    Maybe:
    Formula: copy to clipboard
    IF(AND(A1="true", B1="false", C1="4x6"), 2, 3)
    would return a value of 2 if A1="true" and B1="false" and C1="4x6", otherwise it would return 3.

    Or, to make it dependent on other cells on the row, for example,
    Formula: copy to clipboard
    IF(AND(A1="true", B1="false", C1="4x6"), D1*E1, F1*G1)

  11. #11
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    If you have something like this in X1
    =if(A1="true"(B1="false"(C1="4x6", then "x")
    that will cause problems within a vlookup formula. something like this =if(A1="true"(B1="false"(C1="4x6", then "x") looks like it should be closer to this for syntax purposes =if(AND(A1="true",B1="false",C1="4x6"),"x","") but this would still not return a value in X1 that would do anything for your vlookup. Instead this =if(A1="true",2,IF(B1="false",4,if(C1="4x6",8,""))) those values of 2 or 4 or 8 would tell the vlookup how far over to go to find the value to return for 10251. But without an actual worksheet attached it is difficult to correct formula issues.

  12. #12
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Thanks dudes! I'll work on the cell formula to get a 1-12 value, but what do I put here to reflect that cell value: =VLOOKUP(10251, A1:B6, ????, FALSE)

  13. #13
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    =VLOOKUP(10251, A1:B6, ????, FALSE)
    probably 2 because based on this
    A1:B6 the farthest it can go to the right is over to column B to find the value.

  14. #14
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    So going by what you wrote in post #4 if you have 12 columns of data and they begin in column A that means they go over to column L. If in cell X1 you have an if formula that returns either what is in A1 or B1 or C1 depending on values, say what it returns from A1 is a 4, from B1 it would be a 6 or from C1 it would be a 12, then if your vlookup formula is this =VLOOKUP(10251,A1:L6000,X1,FALSE) and your value in X1 is 4 when the formula finds 10251 in column A between rows 1 and 6000, it will go over to the 4th column (column D in this instance) and return the value there. If it is a 6 it'll return the value in column F, etc.
    from my post #6. If you want something in X1 then I gave you an example of what could be there if it is an IF / THEN statement in post #11
    Instead this =if(A1="true",2,IF(B1="false",4,if(C1="4x6",8,""))) those values of 2 or 4 or 8 would tell the vlookup how far over to go to find the value to return for 10251.
    So you can either hard code a number in the vlookup or use a formula that will give you a result based on the contents of another cell.

  15. #15
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Hardcoding the Index value won't work, because it needs to be variable. What do I put here: =VLOOKUP(10251, A1:B6, ????, FALSE) so that it pulls the content of another cell? Not the result of the formula, but in the formula itself. So if X1 is "4" (X1 being a cell outside of the reference table) what do I put in place of the ???? above so it's "4"?
    Last edited by MattFD; 12-02-2016 at 04:04 PM.

  16. #16
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    see my attached example for how you can use X1 - what is in X1 depends on how you write the if / then formula.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    12-02-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    7

    Re: Vlookup

    Great, so all I need to do is put the cell in the vlookup formula. Thank you.

  18. #18
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Vlookup

    if that solves your problem then don't forget to mark the post as solved using the thread tools dropdown at the top of the post. And since you're new to the forum you can thank ALL those who've stopped by and tried to help you by clicking the "* Add Reputation" at the bottom of one of their posts, that is how we advance on this forum.

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Vlookup

    You're welcome. Thanks for the rep.

+ 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. Using vLookup based on results from a vLookup & returning an undetermined list
    By NormalityBan in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 08-14-2014, 05:02 AM
  2. Replies: 0
    Last Post: 12-26-2013, 01:12 PM
  3. Display Cell within VLookup range that excel thinks matches the VLookup Value
    By headachexcelperson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2013, 04:56 PM
  4. [SOLVED] Vlookup is not working and giving =vlookup(B2,$T$2:$U$135,2,false) this kind of values.
    By yogeshsharma1981 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2013, 04:08 PM
  5. how to bring all vlookup returns even with duplicate vlookup search keys
    By NYC4LIFE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-06-2013, 04:53 PM
  6. vlookup? match? index? MULTIPLE criteria for vlookup search problem....
    By aborg88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2013, 09:56 AM
  7. Replies: 5
    Last Post: 07-29-2009, 07:53 AM

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