Finding Date Closest to Today but Not in the Future

gambit023

New Member
Joined
Jul 14, 2009
Messages
29
Hello all, I'm trying to use conditional formatting to highlight the row of data with a date that is closest to today but not in the future.

I am currently using =$A2=TODAY() in conditional formatting, but this will not highlight the date if today's date is not on the list. I would like to highlight the last in the series of dates that's closest to today but not in the future.

Can someone help?


view

[TABLE="width: 651"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Check #[/TD]
[TD]Payee[/TD]
[TD]Comments[/TD]
[TD] Expense[/TD]
[TD] Deposit[/TD]
[TD]Balance[/TD]
[/TR]
[TR]
[TD="align: right"]1/12/2018[/TD]
[TD][/TD]
[TD]Deposit[/TD]
[TD][/TD]
[TD][/TD]
[TD] $ 3,500.00[/TD]
[TD="align: right"]$7,144.18[/TD]
[/TR]
[TR]
[TD="align: right"]1/12/2018[/TD]
[TD][/TD]
[TD]Cell Phone[/TD]
[TD][/TD]
[TD] $ 70.00[/TD]
[TD][/TD]
[TD="align: right"]$7,074.18[/TD]
[/TR]
[TR]
[TD="align: right"]1/16/2018[/TD]
[TD][/TD]
[TD]Car Payment[/TD]
[TD][/TD]
[TD] $ 281.58[/TD]
[TD][/TD]
[TD="align: right"]$6,792.60[/TD]
[/TR]
[TR]
[TD="align: right"]1/21/2018[/TD]
[TD][/TD]
[TD]Credit Card[/TD]
[TD][/TD]
[TD] $ 229.00[/TD]
[TD][/TD]
[TD="align: right"]$6,563.60[/TD]
[/TR]
[TR]
[TD="align: right"]1/21/2018[/TD]
[TD][/TD]
[TD]Insurance[/TD]
[TD][/TD]
[TD] $ 44.01[/TD]
[TD][/TD]
[TD="align: right"]$6,519.59[/TD]
[/TR]
[TR]
[TD="align: right"]1/21/2018[/TD]
[TD][/TD]
[TD]Withdraw[/TD]
[TD][/TD]
[TD] $ 60.00[/TD]
[TD][/TD]
[TD="align: right"]$1,548.57[/TD]
[/TR]
[TR]
[TD="align: right"]1/29/2018[/TD]
[TD][/TD]
[TD]Gas and Electric[/TD]
[TD][/TD]
[TD] $ 222.25[/TD]
[TD][/TD]
[TD="align: right"]$4,826.32[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I don't think this is possible using conditional formatting alone (Though I hope someone proves me wrong). You will have to use either an array formula or vba (I would use an array formula).

Place this formula in an adjacent cell next to the date, and press cntrl+shift+enter to make the equation an array formula:
=IF(A2=MAX(IF(A:A<TODAY(),A:A,0)),1,0)
Array formula should look like this if done correctly {=IF(A2=MAX(IF(A:A<TODAY(),A:A,0)),1,0)}

Drag/Copy down the formula. This should show a 1 for dates that meet your criteria and a 0 for dates that do not (In your example, a 1 would show for the three records with the date 1/21). From there you can use conditional formatting to highlight the rows where the formula produces the number 1.

Hope this helps.
 
Upvote 0
Hi,

Actually, it is possible:


Book1
ABCDEFGHI
1DateCheck #PayeeCommentsExpenseDepositBalance
21/12/2018Deposit$3,500.00$7,144.18FALSE
31/12/2018Cell Phone$70.00$7,074.18FALSE
41/16/2018Car Payment$281.58$6,792.60FALSE
51/21/2018Credit Card$229.00$6,563.60TRUE
61/21/2018Insurance$44.01$6,519.59TRUE
71/21/2018Withdraw$60.00$1,548.57TRUE
81/29/2018Gas and Electric$222.25$4,826.32FALSE
Sheet7
Cell Formulas
RangeFormula
I2=A2=LARGE(A$2:A$8,COUNTIF(A$2:A$8,">"&TODAY())+1)


Use my sample I2 formula for your CF formula rule.
 
Upvote 1

Excel 2010
ABCDEFG
1DateCheck #PayeeCommentsExpenseDepositBalance
21/12/2018Deposit$3,500.00$7,144.18
31/12/2018Cell Phone$70.00$7,074.18
41/16/2018Car Payment$281.58$6,792.60
51/21/2018Credit Card$229.00$6,563.60
61/21/2018Insurance$44.01$6,519.59
71/21/2018Withdraw$60.00$1,548.57
81/29/2018Gas and Electric$222.25$4,826.32
Sheet27


=$A2:$G8=LOOKUP(TODAY(),$A2:$A8)
 
Last edited:
Upvote 1
Hi,

Actually, it is possible:


Book1
ABCDEFGHI
1DateCheck #PayeeCommentsExpenseDepositBalance
21/12/2018Deposit$3,500.00$7,144.18FALSE
31/12/2018Cell Phone$70.00$7,074.18FALSE
41/16/2018Car Payment$281.58$6,792.60FALSE
51/21/2018Credit Card$229.00$6,563.60TRUE
61/21/2018Insurance$44.01$6,519.59TRUE
71/21/2018Withdraw$60.00$1,548.57TRUE
81/29/2018Gas and Electric$222.25$4,826.32FALSE
Sheet7
Cell Formulas
RangeFormula
I2=A2=LARGE(A$2:A$8,COUNTIF(A$2:A$8,">"&TODAY())+1)


Use my sample I2 formula for your CF formula rule.

=$B2=LARGE(B$2:B$54,COUNTIF(B$2:B$54,">"&TODAY())+1)
only highlights the A column of the row that has the date before or on today. (see snip)

Do you know why?
 

Attachments

  • Screenshot 2024-05-24 123353.png
    Screenshot 2024-05-24 123353.png
    47.3 KB · Views: 15
Upvote 0
Excel 2010
ABCDEFG
1DateCheck #PayeeCommentsExpenseDepositBalance
21/12/2018Deposit$3,500.00$7,144.18
31/12/2018Cell Phone$70.00$7,074.18
41/16/2018Car Payment$281.58$6,792.60
51/21/2018Credit Card$229.00$6,563.60
61/21/2018Insurance$44.01$6,519.59
71/21/2018Withdraw$60.00$1,548.57
81/29/2018Gas and Electric$222.25$4,826.32
Sheet27


=$A2:$G8=LOOKUP(TODAY(),$A2:$A8)
I tried your solution, and it highlighted no rows. (see snip)

Do you know why?
 

Attachments

  • Screenshot 2024-05-24 123248.png
    Screenshot 2024-05-24 123248.png
    37.9 KB · Views: 3
Upvote 0
=$B2=LARGE(B$2:B$54,COUNTIF(B$2:B$54,">"&TODAY())+1)
only highlights the A column of the row that has the date before or on today. (see snip)

Do you know why?
By the way, when I changed the absolute column to a relative column in that formula for the conditional formatting, it highlighted a (to me) random cells in addition to the correct A column cell. (see snip)
 

Attachments

  • Screenshot 2024-05-24 124458.png
    Screenshot 2024-05-24 124458.png
    55.1 KB · Views: 9
Upvote 0
Try it like
Excel Formula:
=$B2=LARGE($B$2:$B$54,COUNTIF($B$2:$B$54,">"&TODAY())+1)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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