Finding the most recent, and oldest dates in a range

Glove303

Board Regular
Joined
Dec 18, 2010
Messages
65
I'm not sure why this doesn't work:
Code:
Sub min_max_date()

Dim MinDate As Date, MaxDate As Date

MinDate = Application.WorksheetFunction.Min(Range(Trades.Cells(5, 2), Trades.Cells(LastRow, 2)))
MaxDate = Application.WorksheetFunction.Max(Range(Trades.Cells(5, 2), Trades.Cells(LastRow, 2)))

End Sub

The range in question is cells that contain dates only.

MinDate and MaxDate only return 00:00:00
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
This works for me, given that the sheet Trades exists (as sheet name, not necessarily what you see in the sheet tabs at the bottom):

Code:
Sub min_max_date()

Dim MinDate As Date, MaxDate As Date

LastRow = 10

MinDate = Application.WorksheetFunction.Min(Trades.Range(Cells(5, 2), Cells(LastRow, 2)))
MaxDate = Application.WorksheetFunction.Max(Trades.Range(Cells(5, 2), Cells(LastRow, 2)))

End Sub
 
Upvote 0
Strange, I wonder why it won't work for me.

Don't worry, the sheet codename is Trades, so it isn't related to that.

It must be that my range is not in proper date format or something...
 
Upvote 0
You could use the function:

=ISNUMBER(B2)

and drag down for the other cells.
 
Upvote 0

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

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