Currently working on a function, and as part of it i need to find the oldest date in a column in VBA. Have spent a while looking for solutions but cant find much. I found one line however it doesn't actually work. Ill post the code snippet I have but any suggestions or solutions would be greatly appreciated!
Public Function SetSOWDates() As String
Dim wsCRC As Worksheet
Set wsCRC = Worksheets("CRC")
Dim LastRowInCRC As Long
LastRowInCRC = CRC.LastRowInCRC()
LatestDate = Format(wsCRC.Max(Range("K8:K" & LastRowInCRC)), "dd/mm/yyyy")
Debug.Print LatestDate
End Function
You want Min
, not Max
for the oldest date, and it's a member of WorksheetFunction
rather than the Worksheet
:
LatestDate = Format(Worksheetfunction.Min(wsCRC.Range("K8:K" & LastRowInCRC)), "dd/mm/yyyy")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With