+ Reply to Thread
Results 1 to 5 of 5

Finding the closest-lower value in a range of data, using 2 variables

Hybrid View

  1. #1
    Registered User
    Join Date
    06-10-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    2

    Finding the closest-lower value in a range of data, using 2 variables

    Hello, I am using Excel 2010 and I have this issue:

    I have an inventory table where I register the entry of products.
    Every time there is an entry of product, I should register its part number, the date of the entry, and the most recent date before the current entry.

    Therefore, I am looking for a formula that automatically allows me to identify the closest date before the current entry of data I mentioned; however, it should only look within the dates that correspond to the item in the row (result 1). I also want to know the position of the cell (result 2) and then change the column (result 3)

    Something like this:

    ITEM DATE OF ENTRY Result I
    A January 1, 2001 "FIRST ENTRY"
    A January 22, 2001 January 20, 2001
    A January 20, 2001 January 1, 2001
    B January 4, 2001 "FIRST ENTRY"
    B January 5, 2001 January 4, 2001

    ITEM DATE OF ENTRY Result II
    A January 1, 2001 "FIRST ENTRY"
    A January 22, 2001 B3
    A January 20, 2001 B1
    B January 4, 2001 "FIRST ENTRY"
    B January 5, 2001 B4

    ITEM DATE OF ENTRY Result III
    A January 1, 2001 "FIRST ENTRY"
    A January 22, 2001 F3
    A January 20, 2001 F1
    B January 4, 2001 "FIRST ENTRY"
    B January 5, 2001 F4

    I think this retrieves the first result I want:

    =IF(MAX(IF(IF($A$2:$A$6=A2,$B$2:$B$6)<B2,IF($A$2:$A$6=A2,$B$2:$B$6)))=0,"FIRST ENTRY",MAX(IF(IF($A$2:$A$6=A2,$B$2:$B$6)<B2,IF($A$2:$A$6=A2,$B$2:$B$6))))

    CTRL+SHIFT+ENTER

    How could I get 2 & 3?

    What do you think?
    Thank you!

    PD. Thanks FDibbins for helping me with the title of the thread.
    Last edited by Vermili0n; 01-30-2015 at 06:47 PM.

  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
    53,048

    Re: Finding the closest-lower value in a range of data, using 2 variables

    Hi, welcome to the forum

    I changed your title for you For future reference, to change a Title on your post, click EDIT POST then Go Advanced and change your title.
    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
    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
    53,048

    Re: Finding the closest-lower value in a range of data, using 2 variables

    Not sure if this is what you want - nor where you intend to put it, but see if this helps,,,

    To find the latest date for an item (before today)...
    =LARGE(IF($A$2:$A$6=A2,$B$2:$B$6,0),1)
    To ID the cell ref for that item...
    ="A"&MATCH(A2&LARGE(IF($A$2:$A$6=A2,$B$2:$B$6,0),1),$A$2:$A$6&$B$2:$B$6,0)+1

    Both of these are ARRAY formulas...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

  4. #4
    Registered User
    Join Date
    06-10-2013
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Finding the closest-lower value in a range of data, using 2 variables

    Quote Originally Posted by FDibbins View Post
    Not sure if this is what you want - nor where you intend to put it, but see if this helps,,,

    To find the latest date for an item (before today)...
    =LARGE(IF($A$2:$A$6=A2,$B$2:$B$6,0),1)
    To ID the cell ref for that item...
    ="A"&MATCH(A2&LARGE(IF($A$2:$A$6=A2,$B$2:$B$6,0),1),$A$2:$A$6&$B$2:$B$6,0)+1

    Both of these are ARRAY formulas...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Thank you! That's great!

    With your insight I could get this:

    For result 1:

    =IF(MAX(IF(IF($A$2:$A$7=A2,$B$2:$B$7)<B2,IF($A$2:$A$7=A2,$B$2:$B$7)))=0,"FIRST ENTRY",MAX(IF(IF($A$2:$A$7=A2,$B$2:$B$7)<B2,IF($A$2:$A$7=A2,$B$2:$B$7))))

    For results 2&3:

    =IFERROR("F"&MATCH(A2&C2,$A$2:$A$7&$B$2:$B$7,0)+1,"FIRST ENTRY")

    Both of them are arrays (CTRL+SHIFT+ENTER).

    I think this covers the whole Issue, I am gonna test this formulas right away!

    - Vermilion

  5. #5
    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
    53,048

    Re: Finding the closest-lower value in a range of data, using 2 variables

    Look forward to hearing back from you

+ 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. Replies: 0
    Last Post: 07-11-2012, 11:06 AM
  2. Finding the closest match between two columns within a given range.
    By cfletcher in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-11-2012, 10:37 AM
  3. Finding the lowest values within a range and add cell to a formula
    By vampyr07au in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-05-2011, 01:05 AM
  4. Excel 2007 : Finding Lowest Number in a range of numbers.
    By stevenson08 in forum Excel General
    Replies: 7
    Last Post: 11-11-2008, 08:19 AM
  5. Finding the 5 lowest values in a range?
    By JamesH in forum Excel General
    Replies: 1
    Last Post: 01-31-2005, 06:59 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