ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Get max & min dates from column (https://www.excelbanter.com/excel-programming/410039-get-max-min-dates-column.html)

miek

Get max & min dates from column
 
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


Mike H

Get max & min dates from column
 
Try,

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


Mike
"miek" wrote:

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


Gary''s Student

Get max & min dates from column
 
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!
--
Gary''s Student - gsnu200781


"miek" wrote:

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


miek

Get max & min dates from column
 
Thanks This worked fine.
I used: d1 = Format(WorksheetFunction.Max(Range("d:d")), "mm/dd/yyyy")

"Mike H" wrote:

Try,

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


Mike
"miek" wrote:

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


miek

Get max & min dates from column
 
Thanks This worked fine.
I used: d1 = Format(WorksheetFunction.Max(Range("d:d")), "mm/dd/yyyy")


"Gary''s Student" wrote:

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!
--
Gary''s Student - gsnu200781


"miek" wrote:

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



All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com