Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default IsArray on Variant/Object/Range returns true??

Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?

thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default IsArray on Variant/Object/Range returns true??

Hi QuantDev,

QuantDev wrote:
Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?


If the variable is truly a Variant, then it cannot contain a reference to a
Range object. When you do this:

Dim v As Variant

v = Range("A1:A10")

The variable v is being filled with the *values* from the range A1:A10. So
the IsArray function is correct - the Variant v really does contain an array
at that point.

Maybe I'm not understanding your issue - what is it you are trying to
accomplish?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsArray on Variant/Object/Range returns true??

Dim v as Variant
set v = Range("A1:A10")

v will hold a range reference.

I assume he has a generalized function that is passed in a variant which may
contain a range. This would be a common need in handling a parmarray

--
Regards,
Tom Ogilvy

"Jake Marx" wrote in message
...
Hi QuantDev,

QuantDev wrote:
Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?


If the variable is truly a Variant, then it cannot contain a reference to

a
Range object. When you do this:

Dim v As Variant

v = Range("A1:A10")

The variable v is being filled with the *values* from the range A1:A10.

So
the IsArray function is correct - the Variant v really does contain an

array
at that point.

Maybe I'm not understanding your issue - what is it you are trying to
accomplish?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default IsArray on Variant/Object/Range returns true??

Thanks for the correction, Tom. I guess I typically use variables of type
Object to do that, so I wasn't even aware (or forgot) you could do the same
thing with a Variant.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Tom Ogilvy wrote:
Dim v as Variant
set v = Range("A1:A10")

v will hold a range reference.

I assume he has a generalized function that is passed in a variant
which may contain a range. This would be a common need in handling
a parmarray


"Jake Marx" wrote in message
...
Hi QuantDev,

QuantDev wrote:
Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?


If the variable is truly a Variant, then it cannot contain a
reference to a Range object. When you do this:

Dim v As Variant

v = Range("A1:A10")

The variable v is being filled with the *values* from the range
A1:A10. So the IsArray function is correct - the Variant v really
does contain an array at that point.

Maybe I'm not understanding your issue - what is it you are trying to
accomplish?

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default IsArray on Variant/Object/Range returns true??

"Jake Marx" wrote in message ...
Thanks for the correction, Tom. I guess I typically use variables of type
Object to do that, so I wasn't even aware (or forgot) you could do the same
thing with a Variant.


Even if you declare it as an object, IsArray will still return true.

The problem here is that it looks like a range is automatically
converted to a variant array whenever a variant is expected.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default IsArray on Variant/Object/Range returns true??

Function TestArray(a)
TestArray = True
On Error Resume Next
If IsError(UBound(a)) Then
TestArray = False
End If
End Function

Stan Scott
New York City

"QuantDev" wrote in message
om...
Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?

thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default IsArray on Variant/Object/Range returns true??

"Stan Scott" wrote in message ...
Function TestArray(a)
TestArray = True
On Error Resume Next
If IsError(UBound(a)) Then
TestArray = False
End If
End Function


I suppose it would return false for 0 dimensioned arrays.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsArray on Variant/Object/Range returns true??

Check for a range first

if typename(varr) is "Range" then
' it's a range
elseif isarray(varr) then
' it's an array

--
Regards,
Tom Ogilvy

"QuantDev" wrote in message
om...
Any idea on how I can check if the variant contains an array,
considered IsArray returns true for ranges?

thanks



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default IsArray on Variant/Object/Range returns true??

"Tom Ogilvy" wrote in message ...
Check for a range first

if typename(varr) is "Range" then
' it's a range
elseif isarray(varr) then
' it's an array

--


Thanks Tom.

As far as you know, am I going to get "true" for isarray for others
variant/object/* combinations?
thx
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsArray on Variant/Object/Range returns true??

I wouldn't think so.

--
Regards,
Tom Ogilvy

"QuantDev" wrote in message
om...
"Tom Ogilvy" wrote in message

...
Check for a range first

if typename(varr) is "Range" then
' it's a range
elseif isarray(varr) then
' it's an array

--


Thanks Tom.

As far as you know, am I going to get "true" for isarray for others
variant/object/* combinations?
thx





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsArray on Variant/Object/Range returns true??

for example:

? isarray(thisworkbook.Sheets)
False
? isarray(Activesheet.Shapes)
False
? isarray(Range("A1"))
False
? isarray(Range("A1:A10"))
True

I can't think of another object that returns an array for the value (or
default) attribute. That doesn't mean there are not any, but I can't think
of one.

--
Regards,
Tom Ogilvy




"QuantDev" wrote in message
om...
"Tom Ogilvy" wrote in message

...
Check for a range first

if typename(varr) is "Range" then
' it's a range
elseif isarray(varr) then
' it's an array

--


Thanks Tom.

As far as you know, am I going to get "true" for isarray for others
variant/object/* combinations?
thx



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
=IF(test,true,false) only ever returns "true"? TagTech Excel Worksheet Functions 5 December 10th 08 03:04 PM
How do I assign range to variant and use Mike H[_2_] Excel Discussion (Misc queries) 7 June 7th 07 01:40 AM
How to define a Range with variant? Yiu Choi Fan Excel Programming 6 July 12th 04 04:41 PM
Best way to paste a variant array into a range? AnneB Excel Programming 2 April 28th 04 09:57 PM
Argument can be a variant or an object onedaywhen Excel Programming 1 September 25th 03 04:20 PM


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