Get max & min dates from column

M

miek

Column "D" has random date values in cells
I need to retrieve the min and max dates from this column and store values
in a varible.
I have tried the following:
Dim d1 As Date
Application.Min (Application.Index(d1, 0, 4)) '4=column D
This just returns a time stamp
 
M

Mike H

Try,

mydatemax = Format(WorksheetFunction.Max(Range("a1:a10")), "dd mm yyyy")
mydatemin = Format(WorksheetFunction.Min(Range("a1:a10")), "dd mm yyyy")


Mike
 
G

Gary''s Student

With dates in column D:

Sub dated()
x = Application.WorksheetFunction.Max(Range("D:D"))
MsgBox (Format(x, "mm/dd/yyyy"))
End Sub

and similar for the min. This is because Dates are really just numbers with
a fancy format!
 
M

miek

Thanks This worked fine.
I used: d1 = Format(WorksheetFunction.Max(Range("d:d")), "mm/dd/yyyy")
 
M

miek

Thanks This worked fine.
I used: d1 = Format(WorksheetFunction.Max(Range("d:d")), "mm/dd/yyyy")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top