+ Reply to Thread
Results 1 to 6 of 6

Need to return date (or column referance) of last criteria match on Attendance Workbook

  1. #1
    Registered User
    Join Date
    05-24-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Need to return date (or column referance) of last criteria match on Attendance Workbook

    Hello my friends,

    I have been struggling with this for a while, so I thought I would ask the helpful members of the forum for their input. I have an attendance sheet with the names in the first columns and the dates in a row. I am tracking vacations, sick and personal days. I would like excel to look at the row and return the date above the last instance where the criteria is met (the date an employee last called in sick). I almost have it working with both the indirect and address functions, but am still not there. I was hoping this can be done with a formula or function, but if it is necessary to use VBA, I am just learning it now, so I'm willing to go that route. I have attached a small sample sheet to illustrate what I am trying to accomplish.

    I thank you all for your wisdom and am thankful that you are willing to share your experience.

    Scott
    Attached Files Attached Files
    Last edited by sdavison; 06-19-2013 at 02:29 PM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Need to return date (or column referance) of last criteria match on Attendance Workboo

    Assuming the S stands for Sick...
    Try this in F6 and filled down

    =LOOKUP(2,1/($G6:$CR6="S"),$G$5:$CR$5)

  3. #3
    Registered User
    Join Date
    05-24-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Need to return date (or column referance) of last criteria match on Attendance Workboo

    Bryan,

    I can't thank you enough! You have solved in minutes what has taken me days to work on. I guess knowledge is everything. Before I mark this post as solved, would you be so kind as to walk me through the first part of the lookup function? I can follow most of it, but the 2,1/ has me a bit stumped. What does it refer to and why does it work. I guess asking questions is the only way to learn.

    Thanks again,

    Scott

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Need to return date (or column referance) of last criteria match on Attendance Workboo

    Glad to help Las Vegas

    This creates an array of Trues and Falses..
    ($G6:$CR6="S")
    Is G6=S, Is H6=S, Is I6=S,etc
    So you get something like
    =LOOKUP(2,1/{True,False,False,True,etc},$G$5:$CR$5)
    In Excel, True = 1 and False = 0
    =LOOKUP(2,1/{1,0,0,1,etc},$G$5:$CR$5)

    Then the 1/ does the devision operation on each 1/0
    1/1 = 1
    1/0 = #VALUE Error

    so now you have
    =LOOKUP(2,{1,#VALUE,#VALUE,1,etc},$G$5:$CR$5)

    Fortunately LOOKUP ignores error values, so it only Sees the 1's.
    Since it's looking for 2 among an Unsorted array with no numbers larger than 1
    It then finds the last numerical value (non error) to the right.
    Then returns the corresponding value from $G$5:$CR$5

    Hope that helps.

  5. #5
    Registered User
    Join Date
    05-24-2013
    Location
    Las Vegas
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Need to return date (or column referance) of last criteria match on Attendance Workboo

    Bryan,

    You are truly an Excel GOD amongst men! Thank you for assisting and taking the time to allow me to understand what the function is doing. It's people like you that make these forums a success. I will now take my new found knowledge and implement.

    Thank you again,

    Scott

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Need to return date (or column referance) of last criteria match on Attendance Workboo

    Las Vegas,

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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