Copying Data between files

G

Guest

Hi

I need to copy data between xls files. File One is a data entry file. I
need to open File Two, look down column A to the last used reference no, add
one this and insert it in the cell below. Then I need to copy specific cells
from File One into cells on this row into columns B, C, D, E & F.

Being a relative novice, any help will be assisted.
 
G

Guest

Hi,

Try the following code. You must record it into a module of you FILE 1.

SUB copy()

dim ACTUAL as string
ACTUAL = ActiveWindow.Caption
Workbooks.Open Filename:= _
"C:\My Documents\FILE 2.xls"
dim NEW as string
NEW = ActiveWindow.Caption
sheets("sheet 1").select
i = 1 ' being 1 the first line of your list
t = True
While t = True
i = i + 1
If Cells(i, 1).Value = "" Then t = False 'being 1 the equivalent to
column "A"
Wend
Range("B" & i).Select
Windows(ACTUAL).Activate
Range("A1").Copy 'Being A1 the cell where you have your data to copy.
Windows(NEW).Activate
Selection.Paste
Range("C"&i).Select
Windows(ACTUAL).Activate
Range("A1").Copy
Windows(NEW).Activate
Selection.Paste
....
.... 'etc, etc, as much columns you want to copy/paste.
end sub

I think it will work.
Take care.
 

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