|
Sub ADO()
Set cn = CreateObject("adodb.connection")
cn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName
Sql = "select disTinct 字母 from [sheet1$A1:B]"
Set RS = cn.Execute(Sql)
Do Until RS.EOF
zm = RS.FIELDS(0)
Set cnn = CreateObject("adodb.connection")
Set RSt = CreateObject("adodb.recordset")
cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & ThisWorkbook.FullName
sqll = "select * from [sheet1$A1:B] where 字母='" & zm & "'"
RSt.Open sqll, cn, 3, 2
n = n + 1
Cells(n + 1, "e") = zm
Cells(n + 1, "f") = RSt.RecordCount
arr = cnn.Execute(sqll).getrows
For i = o To UBound(arr, 2)
Cells(n + 1, "g") = Cells(n + 1, "l") & "," & (arr(1, i))
Next
RS.MOVENEXT
Loop
End Sub |
|