1 打开一个空白的工作簿文件
2 使用该工作簿的Sheet1存放合并后的所有数据行
3 按下<Alt +F11>组合键,打开VBA编辑窗口
4 左侧的工程资源列表中选中工作表Sheet1
5 单击鼠标右键,【查看代码】输入
Sub combin()
dim a as integer
dim TempWk as workbook
dim StartRw as long
dim EndRw as long
dim CurRow as long
filestoopen=application.getopenfilename(filefilter:="Microsoft Excel Files(*.xls;*.xlsx),*.xls;*.xlsx",multiselect:=true,title:="请选择需要合并的工作簿")
if typename(filestoopen)="Boolean" then exit sub
i=1
while i<=ubound(filestoopen)
set TempWk=workbooks.open(filename:=filestoopen(i))
if range("A1048576").end(xlup).row=1 then
StartRw=1
CurRow=1
else
StartRw=2
CurRow=range("A1048576").end(xlup).row+1
end if
EndRw=TempWk.sheets("Sheet1").range("A1048
2 使用该工作簿的Sheet1存放合并后的所有数据行
3 按下<Alt +F11>组合键,打开VBA编辑窗口
4 左侧的工程资源列表中选中工作表Sheet1
5 单击鼠标右键,【查看代码】输入
Sub combin()
dim a as integer
dim TempWk as workbook
dim StartRw as long
dim EndRw as long
dim CurRow as long
filestoopen=application.getopenfilename(filefilter:="Microsoft Excel Files(*.xls;*.xlsx),*.xls;*.xlsx",multiselect:=true,title:="请选择需要合并的工作簿")
if typename(filestoopen)="Boolean" then exit sub
i=1
while i<=ubound(filestoopen)
set TempWk=workbooks.open(filename:=filestoopen(i))
if range("A1048576").end(xlup).row=1 then
StartRw=1
CurRow=1
else
StartRw=2
CurRow=range("A1048576").end(xlup).row+1
end if
EndRw=TempWk.sheets("Sheet1").range("A1048