PC Review


Reply
Thread Tools Rate Thread

Array question

 
 
Greg Snidow
Guest
Posts: n/a
 
      11th Nov 2009
Greetings all. I have read many posts about using arrays in a macro, but I
can't seem to find one elementary enough to suit my needs. I have never used
them, so I need basic stuff. Lets say I have three columns, "Col1", "Col2",
and "Col3", and in those columns I have 1, 2, 3, on row 2, and I have 4, 5, 6
on row three, and so forth, basically just a table of numbers. Is it
possible to use an array to temporarily store the table, then write it to
another sheet? Is there a good place to go for learning how to use them?
Thank you.

Greg
 
Reply With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      11th Nov 2009
Hi Greg,

This answer also on your other post.

Hi Greg,

In the following example it assigns the range values to an array then uses
msgbox to read the values from the 2 dimensional array.

Ensure you use ".Value" on the end of the range when assigning it or it does
not work.

Sub RangeToArray()

Dim arrMyArray()
Dim i As Long
Dim j As Long

With Sheets("Sheet1")
arrMyArray = .Range("A1:C10").Value
End With

'Number elements down (first dimension)
For i = 1 To UBound(arrMyArray)

'Number elements across (second dimension)
For j = 1 To UBound(arrMyArray, 2)
MsgBox arrMyArray(i, j)
Next j

Next i

End Sub

Also Google (or you favourite search engine) "excel vba array tutorial" for
more information

--
Regards,

OssieMac


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
another array question Robert Dieckmann Microsoft Excel Worksheet Functions 4 20th Jan 2007 02:08 AM
Array question Lee Microsoft Excel Programming 1 11th Dec 2003 08:01 PM
Array question Stuart Microsoft Excel Programming 1 6th Aug 2003 04:13 AM
Is this an array question? Stuart Microsoft Excel Programming 0 5th Aug 2003 08:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:37 PM.