|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
欢迎新会员,请测试:- Sub Macro1()
- Dim Fso As Object, File As Object, cnn As Object, SQL$
- Dim objWMI As Object
- Const HKEY_LOCAL_MACHINE = &H80000002
- Set objWMI = GetObject("winmgmts:\\.\root\default:StdRegProv")
- objWMI.SetDWORDValue HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Jet\4.0\Engines\Excel", "TypeGuessRows", 60000
- Application.ScreenUpdating = False
- Set Fso = CreateObject("Scripting.FileSystemObject")
- ActiveSheet.UsedRange.Offset(1).ClearContents
- For Each File In Fso.GetFolder(ThisWorkbook.Path).Files
- If File.Name Like "*.xls" And File.Name <> ThisWorkbook.Name Then
- Set cnn = CreateObject("adodb.connection")
- cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;imex=1';Data Source=" & File
- SQL = "select * from [费用$a8:o] where 费用名称='苹果'"
- Range("g65536").End(xlUp).Offset(1, -6).CopyFromRecordset cnn.Execute(SQL)
- End If
- Next
- Set Fso = Nothing
- cnn.Close
- Set cnn = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|