+ Reply to Thread
Results 1 to 4 of 4

Vlookup if condition applies

  1. #1
    Registered User
    Join Date
    01-05-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    2

    Vlookup if condition applies

    Hi all,

    I'm trying without success to find a formula that give me a value (code) in another sheet (check), if it is the first that happened after.

    excel1.JPG
    excel2.JPG

    I've used a VLOOKUP at first, my problem is that the value code will appear randonly on different times, with different "Check ID", but my Vlookup will aways show the "Check ID" from the first row that have it, I've included a column with the time converted to numbers to make the formula easier, so what I need is to put a formula that find the "Check ID" with the smaller "time in numbers" that is bigger than the one in the current row.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Vlookup if condition applies

    Welcome to the forum!

    What exactly are you trying to achieve?

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    01-05-2018
    Location
    Manchester, England
    MS-Off Ver
    2016
    Posts
    2

    Re: Vlookup if condition applies

    Hi AliGW,

    Thanks a lot for the anwser and info, the sample is attached now, the data is real except by confidential data that I already removed.

    I'll examplify to make easier to understent:

    I work in a warehouse with a very basic system, every time that a picker go to a place and don't find the item that should be there, it generate a check identified by a numeric sequence (sheet Check - Column D) to confirm if it was there or not, what I need to do is find on sheet Check this specific check id attached to that location and item, wich is represented by a code (Sheet Issue - Column A).

    It would be easy to achieve with a vlookup to find the same code from sheet Issue on the sheet Check, the problem is that the same location (code) can have different checks in different moments (never at same time), so the function need to return the check ID in the same row from the same code that happened in the nearest moment after.

    I've highlighted the first 8 rows were I didn't get the desired results in orange.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,567

    Re: Vlookup if condition applies

    I'm not sure that I understand the logic. It would seem that the formula should find
    1) matching codes
    2) the first timestamp in column E on the check sheet that is larger than the time stamp in column F of the issue sheet.
    An array entered formula* that accomplishes that, and in fact produces the desired check ID for 7 of the 8 identified (orange) rows is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The problem is that while it corrects 7 of the 8 issues (row 53, N/A expected, being the exception) it creates 26 more cases where the check ID (column D) doesn't match the desire check ID (column E). Checking a few of those results the formula produces the correct check ID providing my understanding of the logic, listed above, is correct.
    *Array entered formulas are 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.
    If you would like to attempt to understand where the formula results differ then I suggest selecting cell D2 on the issue sheet,
    Pasting the above formula into the formula bar,
    Simultaneously pressing the Ctrl, Shift and Enter keys,
    Double clicking the fill handle.
    Then scroll down to row184, which is the first instance that the formula returns a different code from a previously given (not N/A) desired result. Perhaps inspecting why the formula's result is different from the desired results will help in defining the conditions for the formula.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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] Max Date if one of a few conditions applies
    By FrazierLoans in forum Excel General
    Replies: 16
    Last Post: 06-03-2015, 07:40 PM
  2. Count if the condition applies 2 or more times in a time span:
    By EMyk08 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-24-2014, 09:25 AM
  3. Copy-Paste Special - Transpose values if condition applies
    By Florinnn in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-01-2013, 05:35 AM
  4. how to disable a cell like user cannot input in it when the condition applies ?
    By shaal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 03:47 AM
  5. Conditional Formatting that applies a THEME??
    By RiTz21 in forum Excel General
    Replies: 0
    Last Post: 07-21-2012, 03:29 PM
  6. Macros for inserting row if condition applies in different worksheet
    By Florinnn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2010, 10:54 AM
  7. Index text so that the formatting still applies.
    By RichardDC in forum Excel General
    Replies: 0
    Last Post: 01-20-2005, 12:19 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