Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Issue with arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Dave Peterson, post: 6363011"] I'm not quite sure what you're doing, but you may be able to use application.index() to slice through the matrix: Option Explicit Sub testme() Dim myArr1 As Variant Dim myArr2 As Variant Dim myArr3 As Variant '4x5 matrix myArr1 = ActiveSheet.Range("a1:e4").Value 'second row of myarr1 myArr2 = Application.Index(myArr1, 2) 'third col of myarr1 myArr3 = Application.Index(myArr1, , 3) End Sub But you can loop: Option Explicit Sub testme2() Dim myArr1 As Variant Dim myArr2 As Variant Dim rCtr As Long Dim cCtr As Long '4x5 matrix myArr1 = ActiveSheet.Range("a1:e4").Value 'pick off row 2 ReDim myArr2(LBound(myArr1, 2) To UBound(myArr1, 2)) rCtr = 2 'row 2 For cCtr = LBound(myArr1, 2) To UBound(myArr1, 2) myArr2(cCtr) = myArr1(rCtr, cCtr) Next cCtr 'pick off column 3 ReDim myArr3(LBound(myArr1, 1) To UBound(myArr1, 1)) cCtr = 3 For rCtr = LBound(myArr1, 1) To UBound(myArr1, 1) myArr3(rCtr) = myArr1(rCtr, cCtr) Next rCtr End Sub If you're picking up the values from a range, you could do something like: Option Explicit Sub testme3() Dim myRng As Range Dim myArr2 As Variant Dim myArr3 As Variant '4x5 cells Set myRng = ActiveSheet.Range("a1:e4") 'second row of range myArr2 = myRng.Rows(2).Value 'third col of range myArr3 = myRng.Columns(3).Value End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Issue with arrays
Top