|
请参考:
Sub Macro1()
Dim cnn As Object, SQL$, p$, f$, n&, t$, arr(1 To 65535, 1 To 2)
Application.ScreenUpdating = False
ActiveSheet.UsedRange.Offset(1).ClearContents
Set cnn = CreateObject("ADODB.Connection")
p = ThisWorkbook.Path & "\"
f = Dir(p & "*.xls")
Do While f <> ""
If f <> ThisWorkbook.Name Then
n = n + 1
If n = 1 Then
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;hdr=no';Data Source=" & p & f
Else
t = "[Excel 8.0;hdr=no;Database=" & p & f & "]."
End If
SQL = "select * from " & t & "[汇总表一$b:g] where f1='合计'"
arr(n, 1) = Replace(f, ".xls", "")
arr(n, 2) = cnn.Execute(SQL)(5)
End If
f = Dir()
Loop
Range("a2").Resize(n, 2) = arr
cnn.Close
Set cnn = Nothing
Application.ScreenUpdating = True
End Sub
|
评分
-
3
查看全部评分
-
|