+ Reply to Thread
Results 1 to 7 of 7

If statements inside Lookup function or use VBA to solve an issue

  1. #1
    Registered User
    Join Date
    04-21-2016
    Location
    aasd
    MS-Off Ver
    2013
    Posts
    6

    If statements inside Lookup function or use VBA to solve an issue

    Hi,

    I have two tables (using small ones as example) and I need to find values from one of them. Here is an example:

    sample.xlsx

    As can be seen, what I need is to find values for D2:D5 range. I am not sure what most efficient way to do this would be- use ifs or VBA? I tried to come up with code but am pretty new to these things so any help would be appreciated

    Thanks in advance!
    Attached Images Attached Images

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: If statements inside Lookup function or use VBA to solve an issue

    In D2:
    =INDEX($E$9:$H$12,MATCH(B2,$D$9:$D$12,0),MATCH(C2,$E$8:$H$8,0))

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,723

    Re: If statements inside Lookup function or use VBA to solve an issue

    You have two values of 33 in column D - is this a typo? If not, then how should we choose between them?

    Pete

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If statements inside Lookup function or use VBA to solve an issue

    Here's another one...

    =VLOOKUP(B2,D$8:H$12,MATCH(C2,D$8:H$8,0),0)

    As Pete noted, there are multiple instances of 33 in the lookup table.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    04-21-2016
    Location
    aasd
    MS-Off Ver
    2013
    Posts
    6

    Re: If statements inside Lookup function or use VBA to solve an issue

    Thanks, =VLOOKUP(B2,D$8:H$12,MATCH(C2,D$8:H$8,0),0) is what I need!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,185

    Re: If statements inside Lookup function or use VBA to solve an issue

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: If statements inside Lookup function or use VBA to solve an issue

    You're welcome. Thanks for the feedback!

+ 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. Lookup function issue
    By olliek8 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-18-2015, 10:16 PM
  2. [SOLVED] having hopefully small issue with a lookup formula/function in vba
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2015, 01:02 PM
  3. How to solve listbox inside cells?
    By toplisek in forum Excel General
    Replies: 10
    Last Post: 04-18-2014, 06:54 AM
  4. [SOLVED] Applying the INDIRECT or INDEX function on formula to solve #REF issue
    By Flight777 in forum Excel General
    Replies: 23
    Last Post: 05-24-2012, 09:23 AM
  5. Excel 2007 : performance issue with a lookup function
    By budchevy in forum Excel General
    Replies: 4
    Last Post: 05-17-2011, 05:28 PM
  6. Replies: 2
    Last Post: 06-14-2010, 03:28 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