Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Copy data from workbooks

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)



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy data from workbooks

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 = rngSource(i)

would be one guess. rngSource is already a range reference, so it is
specific to the workbook and worksheet to which it refers.

If you want to use the address of that reference to refer to the same range
in another workbook you could do


Set sourceRNG = Mybook.Range(rngSource(i).address)

--
Regards,
Tom Ogilvy



"Andibevan" wrote in message
...
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)





  #3   Report Post  
Posted to microsoft.public.excel.programming
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Copy data from workbooks


"Dick Kusleika" wrote in message
...
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


Hi Dick,

That part also works for me. The part that doesn't work is Set sourceRNG =
myBook.rngSource(i). I am using arrays as I have about 100 references and
it makes the code more transferable in the future.

I have tried your suggestion and I am able to open the file. Additionally -
I presume that if SRCbook was formatted incorrectly it wouldn't open the
workbook (which it does).

I think if I could get the following to work it would help me sort out my
problem:-

Dim rngSource As Range
Set rngSource = Workbooks("C:\Documents and Settings\abevan\My
Documents\Temp\August 05\SMVIL Project Log.xls").Sheets("Project Log
Form").Range("A8:U79")

It says "Subscript out of range".

Thanks

Andi







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy data from workbooks

Dim rngSource As Range
Dim Mybook as Workbook
Set Mybook = Workbooks.Open ("C:\Documents and Settings\" & _
"abevan\MyDocuments\Temp\August 05\SMVIL Project Log.xls")

set rngSource = Mybook.Sheets("Project Log Form").Range("A8:U79")

--
Regards,
Tom Ogilvy


"Andibevan" wrote in message
...

"Dick Kusleika" wrote in message
...
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


Hi Dick,

That part also works for me. The part that doesn't work is Set sourceRNG

=
myBook.rngSource(i). I am using arrays as I have about 100 references and
it makes the code more transferable in the future.

I have tried your suggestion and I am able to open the file.

Additionally -
I presume that if SRCbook was formatted incorrectly it wouldn't open the
workbook (which it does).

I think if I could get the following to work it would help me sort out my
problem:-

Dim rngSource As Range
Set rngSource = Workbooks("C:\Documents and Settings\abevan\My
Documents\Temp\August 05\SMVIL Project Log.xls").Sheets("Project Log
Form").Range("A8:U79")

It says "Subscript out of range".

Thanks

Andi











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy data from workbooks

actually that should be:

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

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

Set sourceRNG = Mybook.worksheets( _
"Project Log Form").Range(rngSource(i).address)
soureRNG.copy rngsource(i)
Next i

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
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 = rngSource(i)

would be one guess. rngSource is already a range reference, so it is
specific to the workbook and worksheet to which it refers.

If you want to use the address of that reference to refer to the same

range
in another workbook you could do


Set sourceRNG = Mybook.Range(rngSource(i).address)

--
Regards,
Tom Ogilvy



"Andibevan" wrote in message
...
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)







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need macros for copy data into new workbooks Hardeep_kanwar[_2_] Excel Discussion (Misc queries) 2 August 30th 08 04:55 AM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Can't copy data from cells between workbooks within the same excel snakeinbenson Excel Discussion (Misc queries) 7 March 20th 07 08:50 PM
Copy data across workbooks Copy multiple cells New Users to Excel 2 January 12th 06 12:20 AM
text search between workbooks, copy data G8834 Excel Programming 1 June 24th 04 08:07 PM


All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"