|
- 'http://club.excelhome.net/thread-1429224-1-1.html
- Sub 第一列加入薄名参考()
- Updating = False
- Set cnn = CreateObject("adodb.connection")
- [a2:l65536].ClearContents
- h = 2
- f = Dir(ThisWorkbook.Path & "" & "*.xls?")
- Do While f > ""
- If f <> ThisWorkbook.Name Then
- cnn.Open "provider=Microsoft.ACE.OLEDB.12.0;Extended Properties='Excel 12.0;hdr=yes';data source=" & ThisWorkbook.Path & "" & f
- Sql = "select '" & Split(Split(f, "-")(1), ".")(0) & "',* from [省配送甲供$c6:g] where 实用量 is not null"
- Cells(h, 1).CopyFromRecordset cnn.Execute(Sql)
- h = Cells(Rows.Count, 1).End(xlUp).Row + 1
- cnn.Close
- End If
- f = Dir
- Loop
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|