PDA

View Full Version : Copy data from one file to another in Excel



Doc_Clt
06-22-2005, 06:28 AM
Hi. I searched the forums but could only find instances where people were copying from one sheet to another, within the same file.

I was hoping someone could help me figure out a way to copy data from one file to an existing Excel file, which has a 4 row header. Ideally, what I would like is for the cells to be inserted and the existing data below row 4 copied down.

Basically, the scenario is this:

I have an Excel spreadsheet that lists every table and field name from our database (along with some other info). I want to copy information by table to another Excel file so that specs can be created by table. Is there a way to copy from one file to another, where a certain cell equals a certain value? And to only copy to a sheet if the sheet has a name that matches the particular table?

Thanks for all of your help.

NashProjects
12-23-2011, 01:38 AM
dim sWorkbook1 as string
dim sWorkbook2 as string
dim dRow as double

dRow = 4
do until cells(drow,1) = "" 'loops down the cells copying data until the cell is empty

icol = 1
do until icol = 5
workbooks(sWorkbook1).sheets(1).cells(drow,icol) = workbooks(sWorkbook2).sheets(1).cells(drow,icol)
icol = icol+1
loop

drow = drow+1
loop


Hope that helps!

NashProjects
12-23-2011, 01:39 AM
Sorry I forgot important code!!

you will need to give the sWorkbook1 and sWorkbook2 the names of the files you are copying from and to...

Any questions give me a shout