Import a data using a command button

G

Guest

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
 
T

Tom Ogilvy

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
 

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

Top