steve_bris
Registered User.
- Local time
- Tomorrow, 00:35
- Joined
- Mar 22, 2005
- Messages
- 30
Hi.
I am having trouble getting data into an array from Access VBA in excel. I have used this code to get the data in.......but it keeps giving an error. I have tried playing with it but it won't work
This won't cycle throught the rows in J, it just stops and gives an error on J1.........the lrow worked fine and finds the lowest value with some text in it...in the example case 7.
To then use this array i have written the following code....I don;'t know if it works yet as I haven't managed to get any data inot the array
Is this the correct syntax for using an array in the case of comparing if a value is in the array ?
Thanks for any help
Steve
I am having trouble getting data into an array from Access VBA in excel. I have used this code to get the data in.......but it keeps giving an error. I have tried playing with it but it won't work

Code:
Dim Role() As Variant
Dim lrow As Long
Dim i As Long
With Sheets("Sheet1")
[INDENT]lrow = .Range("J65535").End(xlUp).Row
For i = 1 To lrow
[INDENT]Role(i) = .Range("J" & i).Value[/INDENT]
Next
End With[/INDENT]
This won't cycle throught the rows in J, it just stops and gives an error on J1.........the lrow worked fine and finds the lowest value with some text in it...in the example case 7.
To then use this array i have written the following code....I don;'t know if it works yet as I haven't managed to get any data inot the array

Code:
For i = 0 To lrow
[INDENT]If Selection = Role(i) Then
' do stuff to it
End If[/INDENT]Next i
Is this the correct syntax for using an array in the case of comparing if a value is in the array ?
Thanks for any help
Steve