ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ranges as arrays (https://www.excelbanter.com/excel-programming/392712-ranges-arrays.html)

br549

ranges as arrays
 
Is there a problem with:

Dim block(101) as Range

I've also tried block(), block(101), and still get object variable error
messages that point to the first time I try to assign the range block(i).
In my worksheet I have blocks of data of some 50 lines where the data in the
block is from a common date. I have operations I want to perform on each
block of data as a block. My idea was to define each block of common date as
a range, do my calculations on the block, then iterate to the next date code.

Tom Ogilvy

ranges as arrays
 
Sub aa1()
Dim block(101) As Range
For i = 0 To 101
Set block(i) = Range("A1").Offset( _
Int(Rnd() * 100 + 1), Int(Rnd() * 100 + 1)) _
.Resize(Int(Rnd() * 100 + 1), Int(Rnd() * 100 + 1))
Next
End Sub

worked fine for me. Just as a demonstration.

--
Regards,
Tom Ogilvy


"br549" wrote:

Is there a problem with:

Dim block(101) as Range

I've also tried block(), block(101), and still get object variable error
messages that point to the first time I try to assign the range block(i).
In my worksheet I have blocks of data of some 50 lines where the data in the
block is from a common date. I have operations I want to perform on each
block of data as a block. My idea was to define each block of common date as
a range, do my calculations on the block, then iterate to the next date code.


br549

ranges as arrays
 
Thank you. I was trying "block(i)=range....", instead of "set
block(i)=range(....."
Sorry for the stupid question, but thanks for the good answer.

"Tom Ogilvy" wrote:

Sub aa1()
Dim block(101) As Range
For i = 0 To 101
Set block(i) = Range("A1").Offset( _
Int(Rnd() * 100 + 1), Int(Rnd() * 100 + 1)) _
.Resize(Int(Rnd() * 100 + 1), Int(Rnd() * 100 + 1))
Next
End Sub

worked fine for me. Just as a demonstration.

--
Regards,
Tom Ogilvy


"br549" wrote:

Is there a problem with:

Dim block(101) as Range

I've also tried block(), block(101), and still get object variable error
messages that point to the first time I try to assign the range block(i).
In my worksheet I have blocks of data of some 50 lines where the data in the
block is from a common date. I have operations I want to perform on each
block of data as a block. My idea was to define each block of common date as
a range, do my calculations on the block, then iterate to the next date code.



All times are GMT +1. The time now is 07:45 PM.

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