insert data from one excel file into another

L

Leonard

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.
 
H

Huw

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
 
Top