While VBA allows the colon, continuation character, it is generally not recommened. Example, debugging is difficult when using the colons as you can't set breakpoints.
Please set a breakpoint on
dates(k) = highestDate
When you debug, you'll see it's how you're setting the bounds of the array:
dim dates(0)
highestDate = tempdate1
countdate = 1 ' because i have already the first date
k = 0
dates(k) = highestDate ' i put in the first position the first data
'Find the highest Date
For i = 1 To lastRow
If Cells(i, 3).Value = "TIMESTAMP" Then
temp = Cells(i, 4).Value:
temp = Format(temp, "MM-DD-YYYY"):
date1 = CDate(highestDate):
If temp > date1 Then: date1 = temp: countdate = countdate + 1: highestDate = date1:
dates(k) = highestDate
k = k + 1
REDIM PRESERVE dates(k) 'make room in the array!
End If
Next i