我现在写了个VBA 是将一个EXCEL表的内容导入另一个进行汇总,单仅限于一个一个表导入,我现在想批量导入,应该怎么改呢?
VBA :
Sub Sample1()
With Application.FileDialog(msoFileDialogFilePicker)
If .Show = True Then
fn = .SelectedItems(1)
End If
End With
Set wb = GetObject(fn)
wb.ActiveSheet.Copy after:=ThisWorkbook.ActiveSheet
wb.Close False
End Sub
VBA 批量导入EXCEL表
答案:2 悬赏:80 手机版
解决时间 2021-03-12 20:10
- 提问者网友:你给我的爱
- 2021-03-12 09:39
最佳答案
- 五星知识达人网友:爱难随人意
- 2021-03-12 09:47
将Application.FileDialog的AllowMultiSelect属性=TRUE,即可多选文件
Sub Sample1()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect=true
If .Show = True Then
for each c in .SelectedItems
Set wb = GetObject(c)
wb.ActiveSheet.Copy after:=ThisWorkbook.ActiveSheet
wb.Close False
next
End If
End With
End Sub
Sub Sample1()
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect=true
If .Show = True Then
for each c in .SelectedItems
Set wb = GetObject(c)
wb.ActiveSheet.Copy after:=ThisWorkbook.ActiveSheet
wb.Close False
next
End If
End With
End Sub
全部回答
- 1楼网友:傲气稳了全场
- 2021-03-12 09:55
sub printselectsheet()
application.onkey "^{w}", "printselectsheet" '快捷键
dim cx as long
dim strprnsheet as string '当前需要打印的表名
cx = 1
do while activesheet.range("b" & cstr(cx)).value <> ""
if activesheet.range("b" & cstr(cx)).value = 1 then
strprnsheet = activesheet.range("a" & cstr(cx)).value
sheets(strprnsheet).printout preview:=true
end if
cx = cx + 1
loop
end sub
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯