我正在尝试为每组数据做这样的事情。
Sub filt()
Dim nets As ADODB.Recordset
Dim records As ADODB.Recordset
Dim sqlStr As String
sqlStr = "SELECT distinct [Sheet1$].netId FROM [Sheet1$]"
Set nets = queryExecutor(sqlStr)
Do
If Not Isnull(nets(0)) Then
sqlStr = "SELECT * FROM [Sheet1$] WHERE [Sheet1$].netId = '" & nets(0) & "'"
Set records = queryExecutor(sqlStr)
' The type of records is Recordset
Debug.Print "The type of records is " & TypeName(records)
reducer(records)
End If
nets.MoveNext
Loop Until nets.EOF
End Sub
Function queryExecutor(sql As String) As Object
...
End Function
Sub reducer 看起来像这样,当调用sub时,它给我一个运行时错误13,键入不匹配错误
Sub reducer(records As ADODB.Recordset)
...
End Sub
然后我尝试了类似的方法
Sub reducer(records As Object)
' The type of records is Fields
Debug.Print "The type of records is " & TypeName(records)
End Sub
记录的类型似乎变成了字段,我不知道为什么。 我在64位Windows 10系统上运行Excel 2013(32位)。
任何帮助将不胜感激!