Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Assigning Range to Array

I often assign ranges to two-dimensional arrays. I've noticed that I can do
it by declaring the variable as a variant variable, or as an array of
variants. It seems to work either way. Which of these two is better?

Dim MyArray as Variant
MyArray = Range("MyRange").Value

or

Dim MyArray() As Variant
MyArray = Range("MyRange").Value

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Assigning Range to Array

I always do it the first way, but as you say, it doesn't seem to matter.

On Fri, 29 Oct 2004 14:27:01 -0700, Stratuser
wrote:

I often assign ranges to two-dimensional arrays. I've noticed that I can do
it by declaring the variable as a variant variable, or as an array of
variants. It seems to work either way. Which of these two is better?

Dim MyArray as Variant
MyArray = Range("MyRange").Value

or

Dim MyArray() As Variant
MyArray = Range("MyRange").Value


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Assigning Range to Array

I'm not certain, but I think the second fails in versions prior to xl2000.

Alan Beban

Myrna Larson wrote:

I always do it the first way, but as you say, it doesn't seem to matter.

On Fri, 29 Oct 2004 14:27:01 -0700, Stratuser
wrote:


I often assign ranges to two-dimensional arrays. I've noticed that I can do
it by declaring the variable as a variant variable, or as an array of
variants. It seems to work either way. Which of these two is better?

Dim MyArray as Variant
MyArray = Range("MyRange").Value

or

Dim MyArray() As Variant
MyArray = Range("MyRange").Value



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Assigning Range to Array

I think you may be correct. I was thinking, too, that to assign data to
elements of a "normal" array you had to do it cell by cell, with a loop.

On Fri, 29 Oct 2004 16:27:40 -0700, Alan Beban wrote:

I'm not certain, but I think the second fails in versions prior to xl2000.

Alan Beban

Myrna Larson wrote:

I always do it the first way, but as you say, it doesn't seem to matter.

On Fri, 29 Oct 2004 14:27:01 -0700, Stratuser
wrote:


I often assign ranges to two-dimensional arrays. I've noticed that I can

do
it by declaring the variable as a variant variable, or as an array of
variants. It seems to work either way. Which of these two is better?

Dim MyArray as Variant
MyArray = Range("MyRange").Value

or

Dim MyArray() As Variant
MyArray = Range("MyRange").Value




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
Assigning range to array not working Marston Excel Programming 2 August 12th 04 11:38 PM
Assigning 10x1 array to 2nd collumn of 10x3 array Alan Beban[_2_] Excel Programming 0 July 30th 04 01:38 AM
Assigning 10x1 array to 2nd collumn of 10x3 array Myrna Larson Excel Programming 0 July 29th 04 11:57 PM
Assigning array to range inside Excel Object Jon Peltier Excel Programming 0 April 1st 04 11:14 PM
Assigning Array Values MWE[_16_] Excel Programming 6 January 26th 04 04:35 AM


All times are GMT +1. The time now is 12:16 AM.

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"