VBA读取指定工作簿里的一个sheet到我的excelfile怎么做?
展开全部
用getobject方法可以隐藏打开的工作簿对象,实现看上去没有打开的过程
sub test()
dim wb as workbook
dim sht as worksheet
set wb=getobject("C:\A.xls")
set sht=wb.worksheets(1)
sht.Cells.Copy ThisWorkbook.Worksheets(1).[A1]
wb.close
set wb=getobject("C:\B.xls")
set sht=wb.worksheets(2)
sht.Cells.Copy ThisWorkbook.Worksheets(2).[A1]
wb.close
end sub
sub test()
dim wb as workbook
dim sht as worksheet
set wb=getobject("C:\A.xls")
set sht=wb.worksheets(1)
sht.Cells.Copy ThisWorkbook.Worksheets(1).[A1]
wb.close
set wb=getobject("C:\B.xls")
set sht=wb.worksheets(2)
sht.Cells.Copy ThisWorkbook.Worksheets(2).[A1]
wb.close
end sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |