Import a data using a command button
Private Sub Commandbutton1_Click()
Dim bk as Workbook
set bk = Workbooks.Open("C:\DIR2\file2.xls")
bk.worksheets(1).Range("A1:A7").Copy
me.Range("A1:A7").PasteSpecial xlValues
bk.close SaveChanges:=False
End Sub
--
Regards,
Tom Ogilvy
"Mally" wrote in message
...
Hi all.
What I need is fairly simple, i think? I've put it into an example below.
I have two files e.g. C:\DIR1\file1.xls and C:\DIR2\file2.xls.
When i press a command button in file1 I want it to import the data from
cells A1:A7 in file2 and copy the DATA VALUES ONLY into cells A1:A7 in
file1.
I have searched through other questions that have been posted on this page
but nothing really helps me.
Any help most appriciated.
Mally
|