ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy from one to another (https://www.excelbanter.com/excel-programming/288066-copy-one-another.html)

ianripping[_6_]

Copy from one to another
 
Can a macro copy the Information in Book1 Sheet1 Range A:B to Book 2
Sheet1 Range A:B with out Book1.xls being open?


---
Message posted from http://www.ExcelForum.com/


ianripping[_7_]

Copy from one to another
 
I've just figured it out. Here it is for those who wondered: -

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

'
Workbooks.Open Filename:= _
"Book2.xls"
Range("A:B").Select
Selection.Copy
Windows("Book1").Activate
Range("A:B").Select
ActiveSheet.Paste
Windows("Book2.xls").Activate
ActiveWindow.Close
Range("A1").Select
MsgBox ("Completed Copying")
End Su

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Copy from one to another
 
Ian,

So you figured it out as no then?

Your code can be substantiually shortened

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

Workbooks.Open Filename:= "Book2.xls"
Range("A:B").Copy Destination:=Workbooks("Book1").Range("A:B")
Windows("Book2.xls").Close
MsgBox ("Completed Copying")
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ianripping " wrote in message
...
I've just figured it out. Here it is for those who wondered: -

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 15/01/2004 by Ian
'

'
Workbooks.Open Filename:= _
"Book2.xls"
Range("A:B").Select
Selection.Copy
Windows("Book1").Activate
Range("A:B").Select
ActiveSheet.Paste
Windows("Book2.xls").Activate
ActiveWindow.Close
Range("A1").Select
MsgBox ("Completed Copying")
End Sub


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com