VBA discrepancy between Excel 2010 and 2016

UndwaterExcelWeaver

New Member
Joined
Mar 2, 2019
Messages
38
Office Version
  1. 365
Platform
  1. 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.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
If code is hanging when you try to look at references, it will be grayed out. Hit the stop button then see if they're available. When using versions with a fair bit of difference between them, the path to a library may not be valid on some pc's. You could also try running the file as administrator and see if that allows you to view the references. If you manage to do that, I suggest you compile the code as well.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top