I am writing VBA code to find the minimum and maximum dates in a Range. When I execute it, I get an error:
Run-time error '1004': Application-defined or object-oriented error.
Below is my code:
Sub GenerateSheet()
Dim i, r, numAssignments As Integer
Dim ssrRng, DestRange As Range
Dim StartDate, EndDate, d As Date
numAssignments = Sheets("Data").Range("A1048576").End(xlUp).Row - 1
Sheets("Schedule").Select
EndDate = WorksheetFunction.Max(Sheets("Data").Range(Cells(2, 8), Cells(numAssignments, 8)))
StartDate = WorksheetFunction.Min(Sheets("Data").Range(Cells(2, 5), Cells(numAssignments, 5)))
End Sub
Here, Data Sheet has 8 columns, Column 5 and 8 are dates
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…