按ALT+F11,插入一个模块,输入下列代码.即可
Sub copyAll()
fname = "C:\Book2.xls" '需要复制的excel文件地址及文件名,你自己修改
Set d = GetObject(fname) '打开文件
d.sheets("sheet1").Cells.Copy ActiveSheet.Cells(1, 1) '将sheet1完全复制到当前表
d.Close '关闭文件
Set d = Nothing
End Sub
呵呵,录制一个宏就可以啦。下面是我在book1中调用F:\巡检.xls的sheet1:
Workbooks.Open Filename:="F:\巡检.xls", Editable:= _
True
Sheets("sheet1").Select
Sheets("sheet1").Copy After:=Workbooks("Book1").Sheets(1)
Windows("巡检.csv").Activate
ActiveWindow.Close
Book2.xls文件在同一文件夹下
Workbooks.Open ThisWorkbook.Path & "\Book2.xls"
Sheets("sheet1").Cells.Copy Workbooks("Book1").Sheets("sheet1").Cells
ActiveWindow.Close = True