Hi,

Is there a difference between these 2 methods of assignation  :

Range method :

Dim MyArray() as long, rCnt As Long, cCnt As Integer

With Sheet1.Range("A1:C5")
    ReDim MyArray(1 To .Rows.Count, 1 To .Columns.Count)
    MyArray = Sheet1.Range("A1:C5")
End With

Loop method :

with Sheet1.Range("A1:C5")
   redim MyArray(1 to .Rows.Count, 1 To .Columns.Count)
   for i = 1 to .Rows.Count
      for j = 1 to .Columns.Count
         MyArray(i-1,j-1) = .Cells(i,j) ''' I'm not even sure if
it's .Cells(i,j) is the right syntax...the question is not really
about the syntax
      next j
   next i

Are the 2 methods equivalent?

If the range has numbers stored as text along number stored as number,
is everything going to be cast or converted as Long in MyArray. To me
it would be an implicit casting since it relies only on the fact that
MyArray is declared as Long...

Wouldn't it be wiser to use Clong or Cint in the allocation line?

Pascal

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to [email protected]

Reply via email to