|
-
Apr 20th, 2004, 07:47 AM
#1
Thread Starter
Don't Panic!
Excel - VBA - Array and sheet *Resolved*
Hi,
I know that you can put an array into a range and it posts in it beautifully. And Quickly.
Now how do you do the opposite ad get a range into an array of variant??
I tried the opposite :
VB Code:
Redim aryTitles(21)
aryTitles() = shtSrc.Range(shtSrc.Cells(1, 1), shtSrc.Cells(1, 21))
This doesn't work and the array is reset to 0 elements.
Any ideas?
Vince
Last edited by Ecniv; Apr 20th, 2004 at 09:25 AM.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 20th, 2004, 08:09 AM
#2
You need to use a variant to store the returned values, rather than an array. eg:
VB Code:
Dim aryTitles
aryTitles = shtSrc.Range(shtSrc.Cells(1, 1), shtSrc.Cells(1, 21))
-
Apr 20th, 2004, 09:03 AM
#3
Thread Starter
Don't Panic!
Ahh..
Just one variable that is variant... not a redimmed array of variant?
Is this variant variable like an array or do I need to change it into an array?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 20th, 2004, 09:09 AM
#4
Yep.. this way you get a variant containing an array (no need for any conversion), rather than an array or variants.
This is needed as you cant directly assign all values to an array in one statement (but you can set a variant to contain an array).
-
Apr 20th, 2004, 09:13 AM
#5
oh, and by the way (in case you dont know)... the array it returns is dimmed as follows:
(1 to <num rows> , 1 to <num cols>)
-
Apr 20th, 2004, 09:51 AM
#6
Thread Starter
Don't Panic!
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
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
|
Click Here to Expand Forum to Full Width
|