Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default 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.

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
Working with ranges in arrays... or an introduction to arrays Glen Excel Programming 5 September 10th 06 08:32 AM
comparing ranges/arrays asaylor Excel Worksheet Functions 7 June 13th 06 11:53 PM
Ranges and Arrays Will Brown Excel Programming 3 March 12th 05 03:09 PM
Help with Arrays & Ranges in VBA CanQuant Excel Programming 1 February 11th 04 04:24 PM


All times are GMT +1. The time now is 02:06 PM.

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

About Us

"It's about Microsoft Excel"