+ Reply to Thread
Results 1 to 8 of 8

When value isn't found with VLOOKUP - take next cell value

  1. #1
    Registered User
    Join Date
    11-27-2020
    Location
    Denmark
    MS-Off Ver
    Office365
    Posts
    13

    When value isn't found with VLOOKUP - take next cell value

    Hi guys,

    I will try to lay out my problem and hope someone has a good idea :-)

    I have a table with length (column A) (e.g. 2, 2.5, 3, 3.5 and so on) and the price for a length (column B).
    I would like my formula to show the "next price" if it doesn't meet a criteria.

    An example: I put in a value of 2.3 in a cell, and my formula is a simple VLOOKUP with "TRUE" parameter at the end, because else I get a fail.
    This shows the price for 2.0, but I would like to show the price of 2.5 instead of 2.0.

    Anyone can help me on this matter? Maybe I am using the wrong formula for this? :-)

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: When value isn't found with VLOOKUP - take next cell value

    Try this...
    A
    B
    C
    D
    1
    2
    a
    2.3
    b
    2
    2.5
    b
    3
    3
    c
    4
    3.5
    d


    D1=INDEX($B$1:$B$4,MATCH(C1,A1:A4)+1)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    11-27-2020
    Location
    Denmark
    MS-Off Ver
    Office365
    Posts
    13

    Re: When value isn't found with VLOOKUP - take next cell value

    Quote Originally Posted by FDibbins View Post
    Try this...
    A
    B
    C
    D
    1
    2
    a
    2.3
    b
    2
    2.5
    b
    3
    3
    c
    4
    3.5
    d


    D1=INDEX($B$1:$B$4,MATCH(C1,A1:A4)+1)
    Thank you so much, this almost solves the problem - only problem is, if I select 4.0, which has an exact price, it will show the "next price" instead of the price for 4.0 :-)

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: When value isn't found with VLOOKUP - take next cell value

    Problem is that =INDEX($B$1:$B$4,MATCH(C1,A1:A4)+1) would return b when C1 was 2. Looks like the OP wants exact matches when available.

    The old school alternative, =INDEX(B$1:B$4,MATCH(C1,A$1:A$4)+(C1<>LOOKUP(C1,A$1:A$4))) .

    However, OP shows office version as Office 365, so if that means s/he has XLOOKUP, =XLOOKUP(C1,A1:A4,B1:B4,,1) .
    Last edited by hrlngrv; 11-27-2020 at 03:49 AM. Reason: consistency

  5. #5
    Registered User
    Join Date
    11-27-2020
    Location
    Denmark
    MS-Off Ver
    Office365
    Posts
    13

    Re: When value isn't found with VLOOKUP - take next cell value

    Quote Originally Posted by hrlngrv View Post
    Problem is that =INDEX($B$1:$B$4,MATCH(C1,A1:A4)+1) would return b when C1 was 2. Looks like the OP wants exact matches when available.

    The old school alternative, =INDEX(B$1:B$4,MATCH(C1,A$1:A$4)+(C1<>LOOKUP(C1,A$1:A$4))) .

    However, OP shows office version as Office 365, so if that means s/he has XLOOKUP, =XLOOKUP(C1,A1:A4,B1:B4,,1) .
    You guys are awesome! Thank you for the INDEX-formula editing, that made it work smoothly. I am able to make the XLOOKUP formula, but it returns the same value as the first INDEX formula I got from FDibbins.
    It works - I am very grateful for your quick replies - Thanks a lot!

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: When value isn't found with VLOOKUP - take next cell value

    Ford's formula light admendment:

    =INDEX($B$1:$B$4,MATCH(C1-0.001,$A$1:$A$4)+1)
    Quang PT

  7. #7
    Registered User
    Join Date
    07-20-2014
    Location
    Netherlands
    MS-Off Ver
    Office365
    Posts
    1

    Re: When value isn't found with VLOOKUP - take next cell value

    You might sort the table in opposite order and use VLOOKUP without fourth parameter.

  8. #8
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: When value isn't found with VLOOKUP - take next cell value

    XLOOKUP with 5th argument 1 should search for next largest. I works for me that way. I'd guess you believed the 2 consecutive commas were a typo and used 1 as 4th argument.
    Attached Files Attached Files

+ 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] Add a value into a cell found by VLookUp
    By dddddmex in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2020, 08:19 PM
  2. [SOLVED] Vlookup - empty cell if '0' is found
    By LeeBillington in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-23-2017, 04:26 AM
  3. [SOLVED] VLOOKUP and HYPERLINK - Go to found cell
    By Medimatt in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-02-2017, 10:53 AM
  4. Replies: 11
    Last Post: 08-08-2014, 02:40 PM
  5. Return the value above the cell found from vlookup?
    By joshnathan in forum Excel General
    Replies: 4
    Last Post: 01-23-2014, 12:52 PM
  6. [SOLVED] Using cell data relative to another found with vlookup
    By am462 in forum Excel General
    Replies: 1
    Last Post: 11-01-2012, 10:10 AM
  7. How to get the address of the cell found our by vlookup
    By dilettante in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 10:10 PM

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