We are having to use a legacy 2010 version of Excel to run some of our old macros. Can someone tell me what is wrong with this macro, that it runs fine in the 2010 version but not in the 2016 version? I am receiving a mismatch type error on the line in bold below. I'm guessing it's a change in Syntax but the $1700 Excel VBA course I just took still didn't answer my questions. Thanks
Private Function GetDates() As Variant
Dim strSQL As String
Dim rs As New ADODB.Recordset
Dim lstDates() As Date
strSQL = " SELECT DISTINCT(DATE) " & _
" FROM [" & EXTRACTED_FILENAME & "$] "
Call GetResultSet(rs, cn, strSQL)
If (rs.RecordCount > 0) Then
ReDim lstDates(rs.RecordCount - 1) ' <== Error here
Do While (Not rs.EOF)
lstDates(rs.AbsolutePosition - 1) = CDate(rs.Fields(0))
rs.MoveNext
Loop
End If
GetDates = lstDates
End Function
This is just one function as part of a very large extraction macro, but this is the first issue that halts the entire macro.