我有3本练习册,分别是:A,B和C.
我在A中编写一个VBA宏,以便将特定工作表的单元格范围内容从B复制到C.
Dim wb_TC_PBS As Excel.Workbook
Dim wb_SPO_PBS As Excel.Workbook
Set wb_TC_PBS = Workbooks.Open("C:\temp\migration\B.xlsm")
Application.CutCopyMode = False
FinalRow = Sheets("TC_PBS").Cells(Rows.Count, 1).End(xlUp).Row
Range("A5:EO" & FinalRow).Copy
我想了解我的方法是否正确以及如何继续粘贴工作簿C上的内容
答案 0 :(得分:2)
这可能会有所帮助
Dim a As Workbook,b As Workbook, c As Workbook, FinalRow As Long
Set a = ThisWorkbook
Set b = Workbooks.Open("C:\temp\migration\B.xlsm")
Set c = Workbooks.Open("C:\temp\migration\C.xlsm")
b.Activate
FinalRow = b.Sheets("TC_PBS").Cells(Rows.Count, 1).End(xlUp).Row
b.Sheets("TC_PBS").Range("A5:EO" & FinalRow).Copy
c.Activate
c.Worksheets(1).Range("A1").Select
c.Sheet1.Paste
Application.CutCopyMode = False