View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default Copy data from workbooks

Andibevan wrote:
Hi All,

Can someone tell me if the following code is possible:- I get an
"Object does not support this property or method"

Can use arrays in this fashion - Set sourceRNG = myBook.rngSource(i).

I am trying to Open a workbook and copy an array of source ranges to
an array of destination ranges.

Here is an extract from my code:-


Set rngSource(1) = Worksheets("Sheet 1").Range("A8:U79")
Set rngSource(2) = Worksheets("Sheet 2").Range("A7:X10")

Workbooks.Open (SRCbook)
Set myBook = ActiveWorkbook
For i = 1 To UBound(rngSource)


Set sourceRNG = myBook.rngSource(i)


Your code Set myBook = Workbooks.Open(SRCbook) from yesterday's post works
for me. I don't know why you'd be getting an error message on that line.
For copying ranges, I'm not sure why you would use an array. Just copy the
ranges using the Copy method.

Can you open Workbooks(SRCbook) through the UI by using File Open? Maybe
it's not properly formatted and that's why you're getting the error.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com