Hello.
I'm placing a range into a (variant) array but I can't reference the array elements:
Dim EmpIDArray As Variant
EmpIDArray = Range("EmpID")
MsgBox EmpIDArray(3) ' generates subscript out of range error.
Am I missing something straightforward? Thanks, Andy.
Array subscript with Variant
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Array subscript with Variant
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 78463
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Array subscript with Variant
A range is a two-dimensional array, so you have to use for example EmpIDArray(2, 1).
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Array subscript with Variant
Thank you. I was scratching my head for a while..
Andy.
Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.