Copy and Paste ranges between files

D

dude

How do you copy cells from 1 workbook (File A) worksheet (sheet1) to another
workbook(File B) worksheet(sheet2)?

I have sucessfully written a working but not so elegant solution via
activating workbooks.

I am trying to write this without activating files in a loop as it is a less
efficient way of running things.

I am having difficulty wrapping my head around referecing ranges and
worksheets across multiple forms (with out activating).

workbooks("File A").worksheet("sheet1").range(cells(1,1), cells(1,11)).copy

vba returns so sort of application error.

Thanks in advance

R
 
T

Tom Ogilvy

Workbooks("File A.xls").worksheet("sheet1").range( _
workbooks("File A.xls").worksheet("sheet1").cells(1,1), _
workbooks("File A.xls").worksheet("sheet1").cells(1,11)).copy _
Workbooks("File B.xls").worksheets("Sheet2").Range("A1")


or
Dim sh as Worksheet
set sh = workbooks("File A.xls").worksheet("sheet1")
sh.Range(sh.Cells(1,1),sh.Cells(1,11)).Copy _
Workbooks("File B.xls").worksheets("Sheet2").Range("A1")



Regards,
Tom Ogilvy
 

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