|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub qs() '2024/6/28
With Sheet1
Dim Cn As Object, StrSQL$
arr = [{"货币型基金20240603.xlsx","货币型基金20240603";"开放式基金20240603.xlsx","开放式基金20240603"}]
For i = 1 To 2
Set Cn = CreateObject("Adodb.Connection")
Cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" & ThisWorkbook.Path & "\" & arr(i, 1)
StrSQL = "Select * From [" & arr(i, 2) & "$] order by 代码"
k = .Cells(Rows.Count, 1).End(xlUp).Row + 1
Range("A" & k).CopyFromRecordset Cn.Execute(StrSQL)
Set Cn = Nothing
Next
MsgBox "ok"
End With
End Sub |
|