|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我帮你的附件做了适当的修改,具体情况情况附件,只需要把要汇总的文件放在同一个文件夹下,多少个都成,都可以一起合并汇总。
Sub huizong()
Dim str As String
Dim i As Integer
Dim j As Integer
Dim objcn As New ADODB.Connection
Range("a2:d65536").ClearContents
Application.ScreenUpdating = False
str = Dir(ActiveWorkbook.Path & "\*.xls")
Do
If InStr(1, str, "汇总") = 0 Then
objcn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source= " & ThisWorkbook.Path & "\" & str
Sql = "select * from [Sheet1$]"
i = [a65536].End(xlUp).Row + 1
Cells(i, 1).CopyFromRecordset objcn.Execute(Sql)
objcn.Close
Set objcn = Nothing
End If
str = Dir
Loop Until Len(str) = 0
Application.ScreenUpdating = True
End Sub |
评分
-
1
查看全部评分
-
|