Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Ranges into an array.......why doesn't this code work?

Hi guys,

I have two ranges which are stored in an array, Series(1) and
Series(2). I then create a union range:

Set RangeTemp = Application.Union(Series(1), Series(2))

'''So now, RangeTemp holds my range.

'''To check that the range selects ok:

RangeTemp.Select

'''' I also defined:

Dim OverallSelectionRange(1 To 6) As Variant

OverallSelectionRange(2) = RangeTemp

OverallSelectionRange(2).Select <-- This line gives me the error:
'Object Required'


As you can see, I want to assign the range stored in RangeTemp to the
second OverallSelectionRange array element. That line works, but then
the last line gives me the Object Required error. Why is this?? Surely
I am simple assigning a range into that element of the array? Why
doesn't this work?

Regards and thanks,

Tom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Ranges into an array.......why doesn't this code work?

if you want to put a Range Object variable into a variant use

dim vObj as variant

Set vobj=Range("A1:A3")
msgbox vobj.address

vObj now contains a range object, which is just a pointer to the range on
the worksheet

But if you want to retrieve the values from the range into a variant
containing an array then use

dim vArr as variant

varr=Range("A1:A3")
msgbox Varr(1,1)
msgbox varr(2,1)

varr now contains a 2 -dimensional array, 3 rows by 1 column, which contains
the values from the range: its not a range object so trying something like
vARR.Address wil give you "Object required"


Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Tommy" wrote in message
...
Hi guys,

I have two ranges which are stored in an array, Series(1) and
Series(2). I then create a union range:

Set RangeTemp = Application.Union(Series(1), Series(2))

'''So now, RangeTemp holds my range.

'''To check that the range selects ok:

RangeTemp.Select

'''' I also defined:

Dim OverallSelectionRange(1 To 6) As Variant

OverallSelectionRange(2) = RangeTemp

OverallSelectionRange(2).Select <-- This line gives me the error:
'Object Required'


As you can see, I want to assign the range stored in RangeTemp to the
second OverallSelectionRange array element. That line works, but then
the last line gives me the Object Required error. Why is this?? Surely
I am simple assigning a range into that element of the array? Why
doesn't this work?

Regards and thanks,

Tom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Ranges into an array.......why doesn't this code work?

Tommy wrote:
. . .
Dim OverallSelectionRange(1 To 6) As Variant

OverallSelectionRange(2) = RangeTemp

OverallSelectionRange(2).Select <-- This line gives me the error:
'Object Required'


The Select method works on ranges (and other objects), but not on
arrays, which is what OverallSelectionRange is.

Alan Beban
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Ranges into an array.......why doesn't this code work?

I wonder how do you have an array Series storing ranges.
If this was done without problem, i think you could apply the same method to
OverallSelectionRange.

I think it might be something like
Set OverallSelectionRange(2) = RangeTemp

keiji

"Tommy" wrote in message
...
Hi guys,

I have two ranges which are stored in an array, Series(1) and
Series(2). I then create a union range:

Set RangeTemp = Application.Union(Series(1), Series(2))

'''So now, RangeTemp holds my range.

'''To check that the range selects ok:

RangeTemp.Select

'''' I also defined:

Dim OverallSelectionRange(1 To 6) As Variant

OverallSelectionRange(2) = RangeTemp

OverallSelectionRange(2).Select <-- This line gives me the error:
'Object Required'


As you can see, I want to assign the range stored in RangeTemp to the
second OverallSelectionRange array element. That line works, but then
the last line gives me the Object Required error. Why is this?? Surely
I am simple assigning a range into that element of the array? Why
doesn't this work?

Regards and thanks,

Tom


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
Array formula: how to join 2 ranges together to form one array? Rich_84 Excel Worksheet Functions 2 April 1st 09 06:38 PM
Filling an array with ranges Greg Excel Programming 1 November 12th 07 09:24 PM
Ranges in array formulas cottage6 Excel Programming 3 July 20th 05 06:09 AM
Help with Loop / Array / Ranges Kathy - Lovullo Excel Programming 1 December 14th 04 02:59 PM
variant array containing cel adresses convert to actual ranges-array Peter[_21_] Excel Programming 5 December 10th 03 09:50 PM


All times are GMT +1. The time now is 04:19 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"