Fill Array from a Range

R

RyanH

Why can't I fill my array from the range below? I have ensured that the
range is (8 rows X 3 columns).

Dim lngLastRow As Long
Dim aryUserInfo(8, 3) As String

' set array equal to username range
With Workbooks("QG Add-In.xla").Sheets("Login Data")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Error>> aryUserInfo = .Range("B2:D" & lngLastRow).Value
End With
 
G

Gary Keramidas

this works for me. just set a breakpoint on the end sub
then view/locals window

you can then expand the array clicking on the +


Sub test()
Dim lngLastRow As Long
Dim aryUserInfo As Variant

' set array equal to username range
With Worksheets("Login Data")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
aryUserInfo = .Range("B2:D" & lngLastRow).Value
End With
 
J

Jim Cone

Excel 97 does not allow array assignment. In later versions, it is allowed.
--
Jim Cone
Portland, Oregon USA



"RyanH"
wrote in message
Why can't I fill my array from the range below? I have ensured that the
range is (8 rows X 3 columns).

Dim lngLastRow As Long
Dim aryUserInfo(8, 3) As String

' set array equal to username range
With Workbooks("QG Add-In.xla").Sheets("Login Data")
lngLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Error>> aryUserInfo = .Range("B2:D" & lngLastRow).Value
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top