+ Reply to Thread
Results 1 to 5 of 5

Vlookup and its issue when there are repeated ref value

  1. #1
    Registered User
    Join Date
    04-24-2017
    Location
    US
    MS-Off Ver
    MS 2013
    Posts
    7

    Vlookup and its issue when there are repeated ref value

    Hi, I'm not a pro in excel but I do all my report for my company with it. Lately, I got in charge of generating a material report on my project. so I have a unique number for ordering material. using that number I do Vlookup on my report to read from company's material report. unfortunately, that report sucks because it records all requested and Vlookup reads the first status no matter whether it is right or wrong. let's see an example
    Please Login or Register  to view this content.
    my question is:
    is there a way to tell Vlookup to look for the last request date to each WO and read its status?
    I tried to use IF function but didn't work because it is repeated number? I tried to do them manually but that takes time especially when my manager is waiting for my report.

    Do you guys recommend me to learn access and do it with it?

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Vlookup and its issue when there are repeated ref value

    welcome to the forum, sanl_2003. do upload an excel sample so that we do not have to manually key in your data to do a testing. input the desired results so that we don't have to second-guess if what we are doing is correct or not. you may look at my signature to upload an eg that is easier to understand.

    my guess is if your data is in A1:C4, and WO given is in G2, try:
    =LOOKUP(2,1/(($A$2:$A$4=G2)*($C$2:$C$4)),$B$2:$B$4)

    the upload attachment must be done by going to Go Advanced. click on Manage Attachments. Choose file, upload and close the window.
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    04-24-2017
    Location
    US
    MS-Off Ver
    MS 2013
    Posts
    7

    Re: Vlookup and its issue when there are repeated ref value

    thank you so much, Mr.Benishiryo that's what I actually want.

  4. #4
    Registered User
    Join Date
    04-24-2017
    Location
    US
    MS-Off Ver
    MS 2013
    Posts
    7

    Re: Vlookup and its issue when there are repeated ref value

    I really amazed by how simple you look at the issue. I am sorry if I am going to ask you some questions.

    by looking at your solution
    LOOKUP(2,1/(($A$2:$A$4=G2)*($C$2:$C$4)),$B$2:$B$4)
    1- why did you use lookup instead of Vlookup?
    2- #2!! The lookup value? shouldn't be the number is searching for?
    3- For 1/(($A$2:$A$4=G2)*($C$2:$C$4)) what is the value will it return? how did you tell it to chose the newest date? that is so impressive.
    4- I am going to look at all your comment on the forum to keep getting to your professionality.

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Vlookup and its issue when there are repeated ref value

    sure no worries.

    1. well, LOOKUP is more flexible for this scenario where i have to base on WO to get a latest date, and then return a status. VLOOKUP could probably only base on WO to get the latest date. and that is provided that the date is in ascending order.

    2 & 3. i have something similar explained in the file of my link below*in my signature. Tips & Tutorials I Compiled, sheet 6. you may take a look at it. a useful trick for you to learn how formulas work is to select a portion of the formula in the formula bar and press the F9 key to calculate. basically, this portion below is a logical test.
    ($A$2:$A$4=G2)
    it either turns out TRUE or FALSE. Excel recognizes TRUE as 1 and FALSE as 0. so based on your case, if you select the first one and press F9, you will get:
    {TRUE;TRUE;TRUE}
    you will get FALSE if your WO is not 1585.

    ($C$2:$C$4) are your dates. Press F9 would give you:
    {42948;42976;42993}

    so if you multiply TRUE (1) and a number, you still get the same number. press F9 for this and you get the same dates
    ($A$2:$A$4=G2)*($C$2:$C$4)
    {42948;42976;42993}

    1 divided by any number is a maximum of 1. 1 / 0 is DIV Error. 1/1 is 1. 1/100 is 0.01. so 1/(($A$2:$A$4=G2)*($C$2:$C$4)) are numbers smaller than 1:
    {0.0000232839713141473;0.0000232688011913626;0.0000232596004000651}

    my lookup_value is "2", so since the LOOKUP cannot find an exact match, it returns the last number found, and then picks the corresponding Material Status.

    i just realized my formula will not work if your dates are not sorted, since it will always give you the last date even if it's not the latest. if your dates are sorted, you can search instead for an extremely big number and it will return the last one.
    =LOOKUP(99^99,($A$2:$A$4=G2)*($C$2:$C$4),$B$2:$B$4)
    or if your data is unsorted, then:
    =LOOKUP(2,1/(MAX(($A$2:$A$4=G2)*($C$2:$C$4))=($A$2:$A$4=G2)*($C$2:$C$4)),$B$2:$B$4)

    4. you may download my Tips & Tutorial instead. That will be a summary of what i've learnt here.
    Last edited by benishiryo; 09-26-2017 at 11:14 PM. Reason: added a solution for unsorted data

+ 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. Vlookup to get Values for repeated sequence
    By awesomeapoo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-23-2016, 02:30 PM
  2. [SOLVED] Life Cycle Spreadsheet - Issue with repeated recurrence?
    By splottoman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-02-2016, 08:02 AM
  3. [SOLVED] vlookup with highest value in repeated value range
    By hazemrezo in forum Excel General
    Replies: 3
    Last Post: 06-19-2015, 10:42 AM
  4. Vlookup in VBA repeated for multiple rows
    By mgblair in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2015, 06:07 PM
  5. VLookup() error message only at repeated runs
    By bela.bartfai in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-20-2012, 03:10 PM
  6. Vlookup All Repeated Text under same name
    By SBG04 in forum Excel General
    Replies: 4
    Last Post: 07-10-2012, 10:57 PM
  7. [SOLVED] Vlookup with repeated entries/categories
    By Mr.Fish in forum Excel General
    Replies: 6
    Last Post: 05-01-2012, 09:53 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