Sub 复制()
Dim wb As Workbook, wt As Workbook
Set wb = Workbooks("张三.xlsx") '定义工作簿
wb.ActiveSheet.Range("a1:iv" & [A65536].End(xlUp).Row).Select '选择激活工作表的已使用区域
Selection.Copy '复制
Workbooks.Open ("C:\汇总.xlsx") '打开C盘汇总工作簿
Set wt = Workbooks("汇总.xlsx") '定义工作簿
wt.Worksheets("Sheet1").Select '选择汇总工作簿表1
r = [A65536].End(xlUp).Row + 1 '获取有效行最大行号+1的行
Range("a" & r).Select '选择最大行号+1行的A列单元格
Application.WindowState = xlMinimized '粘贴
ActiveSheet.Paste
Workbooks("汇总.xlsx").Close True '保存并关闭汇总工作簿
End Sub
代码写在汇总表中,首先打开汇总表,然後执行代码即可
Dim wb
Set wb = Workbooks.Open("C:\张三.xlsx") '打开张三表
Windows("汇总.xlsx").Activate '选汇总.xlsx为当前工作簿
Workbooks("张三.xlsx").Sheets(1).Copy after:=ActiveWorkbook.Sheets(1) ‘复制
Workbooks("张三.xlsx").Close ’关闭张三表
Set wb = Nothing
希望成功采纳!
把代码放到你要复制到的表中,也就是文件B中
dim wb as workbook
Set Wb = Workbooks.Open(C:\张三.xlsx)
Wb.workSheets(1).Copy After:=Worksheets(1)
wb.close
set wb=nothing
1. 这两个表都要被打开的.然后才能复制
2.等号后应该是workbooks("目标文件名").sheets("表名")
你自己试下,我没这样操作过