作者:乔山办公网日期:
返回目录:excel表格制作
录制宏即可做到,点数据-自文件-导入,自带录制的代码即可完美解决,望采纳
通过VBA中的函数sheets(!百workbook.worksheet).select,就可以将当前的文件指度针指向所选的工作薄中的指知定工作表。道
参数说明:
workbook为工作簿名版即文件名
worksheet为工作表名
当文件指针设权定好后,就可以对指定文件的指定工作表进行操作了。
用vba去遍历知,提取文件道名。资料如下供参考
http://club.excelhome.net/thread-1258425-1-1.html
提取txt文件内容专,可以属通过vba处理
Sub 按钮e799bee5baa6e79fa5e98193e4b893e5b19e3332_Click()
Application.ScreenUpdating = 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 * from [sheet1$A1:C1000]"
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