Return dates from calendar table

Sninge

New Member
Joined
Feb 17, 2019
Messages
4
I have a list of client information (columns A-H) and then after that a year's worth of Mon-Fri dates in I3:KU3. Appointment times have been added into the corresponding cell for the client and date. I have cell C1 which calculates the current date. I want to return 2 entries for each client showing the date of last appointment (today or earlier), and date of next appointment (tomorrow onwards) but can't figure it out. Please help
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I have a list of client information (columns A-H) and then after that a year's worth of Mon-Fri dates in I3:KU3. Appointment times have been added into the corresponding cell for the client and date. I have cell C1 which calculates the current date. I want to return 2 entries for each client showing the date of last appointment (today or earlier), and date of next appointment (tomorrow onwards) but can't figure it out. Please help

Anybody?
 
Upvote 0
Well, here's a go - it's kinda kludgy but appears to work.
2/18/201913I3:KU32/2/20193/1/2019
ClientDte1Dte2Dte3Dte4Dte5Dte6
1JaneDoeRowDRowERowFRowGRowH1/12/20192/2/20193/1/2019
2RichardRowRowDRowERowFRowGRowH8/7/20184/19/2019
3MichalSewRowDRowERowFRowGRowH2/17/20193/1/2019
4SomeoneLowRowDRowERowFRowGRowH12/28/20185/6/2019

<tbody>
</tbody>
Columns A thru H are client data with a client ID in column A.
Columns I thru KU contain dates disbursed through out.
Cell C1 contains Today().
---------------------------------------------------------------------
Now, added helper cells in D1 thru F1 with the latest date prior to today in G1 and the earliest date after today in H1.
D1 = Client ID in the example above it is '1'1
E1 = Row the Client ID is found on=MATCH(D1,A1:A6,0)
F1 = Calendar array of that row="I"&E1&":KU"&E1
G1 = date prior to today=MAXIFS(INDIRECT(F1),INDIRECT(F1),"<"&C1)
H1 = date after today=MINIFS(INDIRECT(F1),INDIRECT(F1),">"&C1)

<tbody>
</tbody>
 
Upvote 0
Hi - Thanks for the reply but the data set you have isn't what I have - my fault for posting on my mobile and not including a data set.

Below is my table.

Today's date is in C1 using the =TODAY() formula. The headers and dates are in row 3. I'm trying to return the dates into Last Visit (Column F) and Next Booking (Column G) based on the times that are already in the table. I have put in the first 4 to show what I want to return.

I want Last Booking to return the last date there was a time entry (including today). If there is no entry for today or previous I want to return "NEW".
I want Next Booking to return the next date there is a time entry (from tomorrow onwards). If there is no future booking I want to return "NO BOOKING".


18/02/2019
FriMonTueWedThuFri
IDNameDataDataDataLast VisitNext Booking15/02/201918/02/201919/02/201920/02/201921/02/201922/02/2019
1Annaxxx18/02/201921/02/201909:0012:00
2BrianxxxNEW19/02/201910:00
3Charliexxx15/02/201922/02/201911:0015:00
4Donnaxxx18/02/2019NO BOOKING12:00
5Evaxxx 08:3015:30

<colgroup><col span="2"><col><col span="2"><col><col><col span="6"></colgroup><tbody>
</tbody>


I've racked my brains and hunted all over Google but can't find a solution. Please help!

Thanks all
 
Upvote 0
Got it to work for the sample given, but it is NOT correct - it's using the value of the max/min found instead of the index to get the relative position to grab the date from the header.
Anybody have an idea as to how to resolve that?
AB19/2/2019DEFGHIJKLMN
FriMonTueWedThuFri
IDNameDataDataDataLast VisitNext Booking15/2/201918/2/201919/2/201920/2/201921/2/201922/2/2019
1Annaxxx18/2/201921/2/20198:309:0012:00
2BrianxxxNEW20/2/201910:00
3Charliexxx15/2/201922/2/201911:0015:00
4Donnaxxx18/2/2019NO BOOKING12:00
5Evaxxx15/2/201920/2/20198:3015:30

<tbody>
</tbody>
Note: This will consistently return the time value for the client's row:
=MAXIFS(I4:KU4,$I$3:$KU$3,"<="&TODAY())
But you need the header date. The below will find the header for the value found, which works for the above, but if you change 8:30 in I4 to 9:00, the date in F2 will change to 15/2/2019.
This was used in F4 and copied down:
=IFERROR(INDEX($I$3:$KU$3,0,MATCH(MAXIFS(I4:KU4,$I$3:$KU$3,"<="&TODAY()),I4:KU4,0)),"NEW")
This is in G4
=IFERROR(INDEX($I$3:$KU$3,0,MATCH(MINIFS(I4:KU4,$I$3:$KU$3,">"&TODAY()),I4:KU4,0)),"NO BOOKING")
 
Upvote 0
Hi, here is another option to try - these are array functions and need to be entered using CTRL+SHIFT+ENTER.


Excel 2013/2016
ABCDEFGHIJKLM
118/02/2019
2FriMonTueWedThuFri
3IDNameDataDataDataLast VisitNext Booking15/02/201918/02/201919/02/201920/02/201921/02/201922/02/2019
41Annaxxx18/02/201921/02/201909:0012:00
52BrianxxxNEW19/02/201910:00
63Charliexxx15/02/201922/02/201911:0015:00
74Donnaxxx18/02/2019NO BOOKING12:00
85Evaxxx15/02/201920/02/201908:3015:30
Sheet1
Cell Formulas
RangeFormula
F4{=IFERROR(LOOKUP(2,IF($H$3:$M$3<=$C$1,IF(ISNUMBER(H4:M4),1)),$H$3:$M$3),"NEW")}
G4{=IFERROR(INDEX($H$3:$M$3,MATCH(1,IF($H$3:$M$3>$C$1,IF(ISNUMBER(H4:M4),1)),0)),"NO BOOKING")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi, here is another option to try - these are array functions and need to be entered using CTRL+SHIFT+ENTER.

Excel 2013/2016
ABCDEFGHIJKLM
118/02/2019
2FriMonTueWedThuFri
3IDNameDataDataDataLast VisitNext Booking15/02/201918/02/201919/02/201920/02/201921/02/201922/02/2019
41Annaxxx18/02/201921/02/201909:0012:00
52BrianxxxNEW19/02/201910:00
63Charliexxx15/02/201922/02/201911:0015:00
74Donnaxxx18/02/2019NO BOOKING12:00
85Evaxxx15/02/201920/02/201908:3015:30

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
F4{=IFERROR(LOOKUP(2,IF($H$3:$M$3<=$C$1,IF(ISNUMBER(H4:M4),1)),$H$3:$M$3),"NEW")}
G4{=IFERROR(INDEX($H$3:$M$3,MATCH(1,IF($H$3:$M$3>$C$1,IF(ISNUMBER(H4:M4),1)),0)),"NO BOOKING")}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>

This worked perfectly - thank you so much :)
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top