+ Reply to Thread
Results 1 to 4 of 4

Find the Last Occurrence of cell value after matching date.

  1. #1
    Registered User
    Join Date
    11-04-2020
    Location
    Birmingham, United Kingdom
    MS-Off Ver
    2016
    Posts
    7

    Find the Last Occurrence of cell value after matching date.

    Hi All,

    I have a duty Rota on Excel. Each month will only show Working Days in a week. So each month will be different. So for example the 1st may be on a Monday or it may be a Friday. The weekends and holidays have been blacked out. I am trying to pull the data into a 4 day rota view. What I want is to match the date and then look for the previous version of cell "Duty Manager" (as the Duty Manager is the same all week).

    Right Now I have a Formula:
    =IF(COUNTIF($A$10:$A$42,T2)>0,IF($B$10="Duty Manager",INDEX($C$10:$C$41,INT((MATCH(T2,$A$10:$A$41)-1)/7)*7+1),INDEX($C$10:$C$41,INT((MATCH(T2,$A$10:$A$41)-1)/7)*7+2)),IF(COUNTIF($F$10:$F$42,T2)>0,IF($G$10="Duty Manager",INDEX($H$10:$H$41,INT((MATCH(T2,$F$10:$F$41)-1)/7)*7+1),INDEX($H$10:$H$41,INT((MATCH(T2,$F$10:$F$41)-1)/7)*7+2)),IF(COUNTIF($K$10:$K$42,T2)>0,IF($L$10="Duty Manager",INDEX($M$10:$M$41,INT((MATCH(T2,$K$10:$K$41)-1)/7)*7+1),INDEX($M$10:$M$41,INT((MATCH(T2,$K$10:$K$41)-1)/7)*7+2)),"Not Found")))

    This seemed to work last month - but not for December or January 2021. I have attached a sample sheet. What I would like is in the table X2:X5 - is to match todays date (7th December 2020) - look up previous occurrence of "Duty Manager" and Return "C Person".

    Hope this makes sense?

    Jabba
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Find the Last Occurrence of cell value after matching date.

    Please try at X2

    =LOOKUP(2,1/(INDEX($A$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,))<T2)/(INDEX($B$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,))=X$1),INDEX($C$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,)))
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-04-2020
    Location
    Birmingham, United Kingdom
    MS-Off Ver
    2016
    Posts
    7

    Re: Find the Last Occurrence of cell value after matching date.

    Hi Bo_Ry,

    Perfect!! Thank you for such a quick response. This forum never ceases to amaze me for help and guidance...long may it continue.

    Jabba

    Quote Originally Posted by Bo_Ry View Post
    Please try at X2

    =LOOKUP(2,1/(INDEX($A$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,))<T2)/(INDEX($B$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,))=X$1),INDEX($C$10:$M$41,,MATCH(TEXT(T2,"mmmm yyyyy"),$A$9:$M$9,)))

  4. #4
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365
    Posts
    1,397

    Re: Find the Last Occurrence of cell value after matching date.

    Jabtastic,

    Was working through your question when Bo_Ry posted the solution, but thought the attached might still have some use for you?

    Cols A , E and I show both the weekday and date.
    As B3 says the Year has to start in April, put in C3 1/4/(whatever year).
    That sets the Month sequence in Col N, which populates the DropLists in B5, F5 and J5.
    What you select generates the dates in Row 11, with the remaining dates cascading from the first entry, until the date is later than the end of the month, when cell goes blank:

    =IFERROR(IF(A11+1>EOMONTH(B$5,0),"",A11+1),"")

    CF for the Saturday is =WEEKDAY(A11,1)=7 and for Sunday =WEEKDAY(A11,1)=1, applying to all three tables.

    Hope you find it makes life simpler and even speeds up the file?

    Ochimus
    Attached Files Attached Files
    Last edited by Ochimus; 12-07-2020 at 07:40 PM.

+ 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] Find Row number of First and Last occurrence matching values in 2 columns
    By muralidaran in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-02-2020, 08:09 AM
  2. [SOLVED] Find a Cell's Value Based on Matching Date from an Adjacent Cell
    By SBLR01 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-10-2019, 10:11 PM
  3. Find the latest occurrence of date in the row
    By goodboy in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-10-2016, 07:00 AM
  4. [SOLVED] Find the first occurrence of any Date in a column
    By maw230 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-14-2014, 02:43 PM
  5. Find occurrence of one word more than once in a cell
    By amandeepsharma89 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-12-2013, 12:48 AM
  6. Replies: 2
    Last Post: 03-31-2012, 01:08 AM
  7. Excel 2007 : Find Date of Last Occurrence
    By Twill413 in forum Excel General
    Replies: 3
    Last Post: 09-15-2011, 11:33 AM

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