I am trying to find by formula or vba, the earliest and or latest date in a autofiltered range with the data residing in cells G11 to last row.
I am trying to find by formula or vba, the earliest and or latest date in a autofiltered range with the data residing in cells G11 to last row.
Remember To Do the Following....
Use [Code].... [/Code] tags when posting code to the thread.
Mark your thread as Solved if satisfied by using the Thread Tools options.
If posting the same issue to another forum please show the link
I am assuming that you have the coding done for the AutoFilter:
Does this help?
[vba]
Dim EarliestDate As Date, LatestDate As Date
With Application.WorksheetFunction
EarliestDate = .Min(Range("G:G").SpecialCells(xlCellTypeVisible))
LatestDate = .Max(Range("G:G").SpecialCells(xlCellTypeVisible))
End With
[/vba]
or if you only want to zero in on G11 to LastRow
[vba]
Dim LastRow As Long, EarliestDate As Date, LatestDate As Date
LastRow = Cells(Rows.Count, "G").End(xlUp).Row
With Application.WorksheetFunction
EarliestDate = .Min(Range("G11:G" & LastRow).SpecialCells(xlCellTypeVisible))
LatestDate = .Max(Range("G11:G" & LastRow).SpecialCells(xlCellTypeVisible))
End With
[/vba]
Max: =SUBTOTAL(104,OFFSET(G11,,,COUNTA(G:G)-COUNTA(G1:G10),1))
Min: =SUBTOTAL(105,OFFSET(G11,,,COUNTA(G:G)-COUNTA(G1:G10),1))
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber