Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy data from one workbook to another

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
Using VisualBasic code...
There are two workbooks. I will call them BookOne.xls and BookTwo.xls. BookOne.xls has a worksheet called SheetOne and BookTwo.xls has a worksheet called SheetTwo.

I have both workbooks open. Using VB code how do I copy the contents of cell "A1" from

BookOne.xls SheetOne

into

BookTwo.xls SheetTwo

Any ideas?
Thank you.
 
Excel has one very useful feature called the Macro Recorder. From the menu: Tools / Macro / Record New Macro... Using the tool produced the following macro to do what you want:
Code:
Sub Macro1()
Code:
'
' Macro1 Macro
' Macro recorded 4/19/2003 by Zathras
'

'
Code:
    Windows("BookOne.xls").Activate
    Sheets("SheetOne").Select
    Range("A1").Select
    Selection.Copy
    Windows("BookTwo.xls").Activate
    Sheets("SheetTwo").Select
    Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub
 
Hi! Can you get the same result WITHOUT opening BookTwo.xls? Thanks!
 
No, AFAIK. But why not just use a direct link. I.e. in Book2, simply use this formula in A1:
Code:
   =[BookOne.xls]SheetOne!$A$1
The next time BookTwo is opened the linked cell(s) will be updated.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top