Find closest date to today

solarissf

New Member
Joined
May 23, 2011
Messages
4
Hello All,

I have a column that is NOT sorted and cannot be (with dates in it). I want to search the column, and highlight the cell that is closest to today.

I found this post, but does not work for me.

http://www.mrexcel.com/forum/showthread.php?t=326266

I believe it is because, if I try and convert the dates to NUMBERS, it will not let me. Possibly the source of the data is doing something to the format that will not let me switch the format.

Any ideas for finding the closest date?

thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello All,

I have a column that is NOT sorted and cannot be (with dates in it). I want to search the column, and highlight the cell that is closest to today.

I found this post, but does not work for me.

http://www.mrexcel.com/forum/showthread.php?t=326266

I believe it is because, if I try and convert the dates to NUMBERS, it will not let me. Possibly the source of the data is doing something to the format that will not let me switch the format.

Any ideas for finding the closest date?

thanks
Which date is closest to today (5/23/2011) and should be highlighted:

5/22/2011
5/24/2011
 
Upvote 0
I should have mentioned... the dates will always be sometime in the future... they will never be in the past.
 
Upvote 0
Hello All,

I have a column that is NOT sorted and cannot be (with dates in it). I want to search the column, and highlight the cell that is closest to today.

I found this post, but does not work for me.

http://www.mrexcel.com/forum/showthread.php?t=326266

I believe it is because, if I try and convert the dates to NUMBERS, it will not let me. Possibly the source of the data is doing something to the format that will not let me switch the format.

Any ideas for finding the closest date?

thanks

Control+shift+enter, not just enter:

=INDEX(A2:A15,MATCH(MIN(ABS(A2:A15-TODAY())),ABS(A2:A15-TODAY()),0))

where A2:A15 houses a sample of (unsorted) dates. Format the formula cell
as date. Note that a date is simply an integer (number) in Excel.
 
Upvote 0
that is the problem... there is something screwy with the source format. It will not let me format date to a number. Which leads me to believe maybe its some sort of text or custom.
 
Upvote 0
I should have mentioned... the dates will always be sometime in the future... they will never be in the past.
If the dates will always be in the future then all you need is the minimum date. The earliest date will be the closest to today's date.

=MIN(A1:A10)

Format as Date
 
Upvote 0
here seems to be the problem, when I copy and paste the date to a new sheet
Range(Cells(startRow, 1), Cells(endRow, 12)).Activate
Selection.Copy
Workbooks("FirstNoticeEmail.xlsx").Worksheets(1).Range("A7").PasteSpecial
Workbooks("FirstNoticeEmail.xlsx").Worksheets(1).Range("A7").PasteSpecial Paste:=xlPasteColumnWidths

that is where I lose the ability to see date as a number.
idea how to change this pasting code to save format type
 
Upvote 0
here seems to be the problem, when I copy and paste the date to a new sheet
Range(Cells(startRow, 1), Cells(endRow, 12)).Activate
Selection.Copy
Workbooks("FirstNoticeEmail.xlsx").Worksheets(1).Range("A7").PasteSpecial
Workbooks("FirstNoticeEmail.xlsx").Worksheets(1).Range("A7").PasteSpecial Paste:=xlPasteColumnWidths
that is where I lose the ability to see date as a number.
idea how to change this pasting code to save format type
Sorry, can't help you with that!
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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