-
Solved: Loading a range into a matrix
Hi folks;
anyone able to tell me how I can load a (named) range into a matrix, without loading each element one at a time? If I run someting like:
[vba]
Option Explicit
Option Base 1
Private myMatrix As Variant
Private Sub UserForm_Initialize()
myMatrix = Range("TestRange")
MsgBox UBound(myMatrix)
MsgBox LBound(myMatrix)
MsgBox myMatrix(5)
End Sub
[/vba]
with TestRange a named range, it shows correct UBound, but I get a 'Subscript out of range" when I want to show a matrix value..
I am obviously missing something... but what?
Thymen
-
Hi
what do you want to do with this line?
MsgBox myMatrix(5)
-
Show the value of myMatrix item 5. The named range is 1 column wide / 10 rows deep. So, with msgbox myMatrix(5) I should get a message showing the value ot the 5th row....
Just to indicate that the matrix got filled with data.
Thymen
-
then
msgbox myMatrix(5,1)
sorry, but I must go off-line now,
Remenber when you convert range value to an array
the array is always 2D array, regardless of the number of row/column..
-
Thanks, I'll tried that and it works....
Thymen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules