Hi All,
I want to copy cells A1:A5 from "book1" into "book2", but if "book2" isn't open, i want the macro to open it, copy the cells into it, then save "book2". I have the below, but it doesn't work because I don't think i'm referencing the workbooks correctly? Both are saved on my desktop.
Any help is greatly appreciated.
Sub copybetweenworkbook()
Workbooks.Open Filename:="c:\book2.xlsx"
Workbooks.book1.xls.Sheets("Sheet1").Range("A1:A5").Value = Workbooks.book2.xlsx.Sheets("Sheet1").Range("A1:A5").Value
Workbooks("book2.xlsx").Activate
ActiveWorkbook.Save
End Sub
I want to copy cells A1:A5 from "book1" into "book2", but if "book2" isn't open, i want the macro to open it, copy the cells into it, then save "book2". I have the below, but it doesn't work because I don't think i'm referencing the workbooks correctly? Both are saved on my desktop.
Any help is greatly appreciated.
Sub copybetweenworkbook()
Workbooks.Open Filename:="c:\book2.xlsx"
Workbooks.book1.xls.Sheets("Sheet1").Range("A1:A5").Value = Workbooks.book2.xlsx.Sheets("Sheet1").Range("A1:A5").Value
Workbooks("book2.xlsx").Activate
ActiveWorkbook.Save
End Sub