|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub datas()
Dim Fso As Object, File As Object, cnn As Object, SQL$, n&, r&
Application.ScreenUpdating = False
Range("A4:J65536").ClearContents
Set Fso = CreateObject("Scripting.FileSystemObject")
Set cnn = CreateObject("adodb.connection")
For Each File In Fso.GetFolder(ThisWorkbook.Path).Files
If File.Name Like "*.xls" And File.Name <> ThisWorkbook.Name Then
n = n + 1
If n = 1 Then cnn.Open "provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0;data source=" & File
SQL = "select f2,f3,f4,f5,f6,f7,f8,f9,f10 from [Excel 8.0;hdr=no;Database=" & File & ";].[Data$B25:K]"
r = [b65536].End(xlUp).Row + 1
Cells(r, 1) = Replace(File.Name, ".xls", "")
Range("b" & r).CopyFromRecordset cnn.Execute(SQL)
End If
Next
cnn.Close
Set cnn = Nothing
Set File = Nothing
Set Fso = Nothing
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|