UndwaterExcelWeaver
New Member
- Joined
- Mar 2, 2019
- Messages
- 38
- Office Version
- 365
- Platform
- Windows
Hello,
I have posted a similar issue in the past and didn't really get anywhere.
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 teh 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. I received a suggestion to the last post about a missing library. The "references" selection under "tools" is greyed out in both 2010 and 2016 versions when this file is open. 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)
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.
I have posted a similar issue in the past and didn't really get anywhere.
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 teh 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. I received a suggestion to the last post about a missing library. The "references" selection under "tools" is greyed out in both 2010 and 2016 versions when this file is open. 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)
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.