insert data from one excel file into another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to insert data from one excel file into another without
doing copy and pasting? I need to automate the process of inserting data but
I cannot use copy-paste, because it puts data on a clipboard, and my Excel
VBA program runs in a multi-user environment. So if one instance of a program
is copying data into clipboard, and another instance is pasting it at the
same time, it will paste incorrect data.

Thank you

Leonard.
 
You'll need both spreadsheets open, but try this;

Option Explicit

Sub MyMacro()
Dim MyVariable As String

Windows("File2.xls").Activate 'Use the window name to select the file
MyVariable = Range("A1") 'Use a variable to store the data from "A1".

Windows("File1.xls").Activate 'Select the second workbook.
Range("A1").Select 'Select cell "A1".
ActiveCell.Text = MyVariable 'Use .Text to copy the data.
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top