I have a column of unknown length (column Q) and I want to find the earliest and latest dates in this column. The first entry is in cell "Q2". The Dates are not arrange chronologically, so I can't simply look at the first and last row. Furthermore, I would like to paste all the months between the two dates in a new Worksheet. I have tried to find the earliest and latest dates, but I am already strugling with the code. Here is an extract of my code:
Dim SDate As Date, LDate As Date
Dim last_row As Long
Dim LastCell As String
last_row = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
LastCell = "Q" & last_row
Worksheets("Sheet1").Select
SDate = WorksheetFunction.Min(Range("Q2:LastCell"))
EDate = WorksheetFunction.Max(Range("Q2:LastCell"))
It tells me that it does not recognize the value LastCell as an input for Range. [The date format in Sheet1 is dd.mm.yyyy]
As Output in Sheet2, I would like for it to look something like this (Starting in Cell D2):
Can anyone help me out? I am pretty new to VBA
Thank you in advance Sam