ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying Data between files (https://www.excelbanter.com/excel-programming/373811-copying-data-between-files.html)

Steve

Copying Data between files
 
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.

pmonica

Copying Data between files
 
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.
--
Paulo Mónica


"Steve" wrote:

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.



All times are GMT +1. The time now is 10:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com