Access Accessing arrays within loop - VBA

Joined
May 19, 2013
Messages
2
Reaction score
0
I have 9 arrays (arr1....arr9) and 9 variables of type string (var1....var9). My question is how can I REDIM the arrays using a FOR-NEXT loop so that the number of elements of each array equals the length of its corresponding variable. I want to put the strings into arrays to speed-up my macro.
 
If I understand what you are trying to do correctly, the code is as follows:

Code:
Dim arr1(0) As String
 
Dim var1 As String
 
'some code here
 
ReDim Preserve arr1(0 To UBound(arr1()) + 1)
 
'more code here

I should add that this assumes that you are adding the variables in a specific order and, of course, validating that data at some point! This may not be exactly what you were asking but I think it should get the point across. Any questions, feel free to let me know.
 
Back
Top