|
Sub 查询()
Dim cnn As Object
Dim Sql As String, i%, M%
Set cnn = CreateObject("ADODB.CONNECTION")
cnn.Open "Provider=Microsoft.Jet.OleDb.4.0;Extended Properties='Excel 8.0;HDR=no'; Data Source=" & ThisWorkbook.FullName
For i = 1 To 62 Step 2
Sql = Sql & "SELECT F" & i & ",F" & i + 1 & " FROM [明细$a2:bj500] union all "
Next
Sql = Left(Sql, Len(Sql) - 11)
Sql = "select F1,SUM(F2) from (" & Sql & ") WHERE F2 IS NOT NULL GROUP BY F1"
[A:B] = ""
[a2].CopyFromRecordset cnn.Execute(Sql)
cnn.Close: Set cnn = Nothing
End Sub |
评分
-
2
查看全部评分
-
|