ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What type of Array is this? (https://www.excelbanter.com/excel-programming/332999-what-type-array.html)

davidm

What type of Array is this?
 

The following code returns *Variant()* as the Array type of
Range("a1:a100").

Sub DetermineArrayType()
Dim v
v = Range("a1:e100").value
Msgbox Typename(v)
End Sub

And yet the next code does not recognize the same Range as an array as
an error is returned on *v = Range("a1:e100").value*.

Sub DetermineArrayType2()
Dim v(1 To 100, 1 to 5)
v = Range("a1:e100").value
Msgbox Typename(v)
End Sub

Any explanation?


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=382706


Charles Williams

What type of Array is this?
 
A variant variable can contain anything, including an array.
You can also have an array of variants.
A variant containing an array is not the same thing as an array of variants.

Your first case is a variant containing an array (this is the correct syntax
for retrieving data from a range)
Your second case is an array of variants.

Charles
______________________
Decision Models
FastExcel 2.1 now available
www.DecisionModels.com

"davidm" wrote in
message ...

The following code returns *Variant()* as the Array type of
Range("a1:a100").

Sub DetermineArrayType()
Dim v
v = Range("a1:e100").value
Msgbox Typename(v)
End Sub

And yet the next code does not recognize the same Range as an array as
an error is returned on *v = Range("a1:e100").value*.

Sub DetermineArrayType2()
Dim v(1 To 100, 1 to 5)
v = Range("a1:e100").value
Msgbox Typename(v)
End Sub

Any explanation?


--
davidm
------------------------------------------------------------------------
davidm's Profile:
http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=382706




davidm

What type of Array is this?
 

Many thanks Charle

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=38270



All times are GMT +1. The time now is 01:26 AM.

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