How to return the max date in a range?

Asked by At

Complete beginner here, I need to find the max (most recent) date in a column and copy it onto a new autogenerated worksheet.

Using Application.WorksheetFunction.Max doesn't seem to be working for me. What am I doing wrong?

dtrng (date range) is a range, dtcom (date completed) and dtcom2 are strings. Unsure if this is what they should be. ws is the original worksheet. The code to copy them over is this:

Set dtrng = ws.Range("S4:S1000")
    dtcom = Application.WorksheetFunction.Max(dtrng)
    dtcom2 = CDate(dtcom)

Currently it's just giving me a 0.

Cheers, EJ

0 Answers