Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with arrays 2

Status
Not open for further replies.

rgandy

Technical User
Nov 17, 2005
38
US
How can I place a range into an array
ie.
TestArray = range("TestRange")
where test range is the range ("a1:z20")

and then grab the first row of data with one line of code?

ie. grab the contents of ("a1:z1") for manipulation

(for this particular example i want to take this data and output it to a range)

thanks!

 

To answer your qustion, you can use a variant like this:
Code:
Sub test()
Dim TestArray
  TestArray = Range("A1:Z20")
  MsgBox TestArray(2, 2)
End Sub
But to accomplish what you want to do, don't use an array, use ranges like this:
Code:
Sub test2()
Dim r As Range
  Set r = Range("A1:Z20").Rows(1)
  MsgBox r.Address
End Sub
 

rgandy,

Just to piggy-back on Zathras' suggestion, take a look at Collections & Objects in the VB Help. There are all kinds of Collections of Objects in Excel.

Skip,

[glasses] [red]Be Advised![/red]
The band of elderly oriental musicians, known as Ground Cover, is, in reality...
Asian Jasmine![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top