1

I want to pass array name as string.

 Dim i as Integer
 Dim arName as String
 Dim ar1(10) as Integer 'array of 10 elements
 Dim ar2(10) as Integer
 Dim ar3(10) as Integer

 for i = 1 to 3
     arName ="ar" & i
     arName(1)=34 ' I want 34 in every 1st element of all three arrays 
 Next i
 End sub

I am doing this as Array practice. How to pass Array Name as string is my question

1

1 Answer 1

1

Just create a single multi-dimensional array

Dim i As Integer
Dim arr(1 To 3, 1 To 10) As Integer
For i = 1 To 3
    arr(i, 1) = 34
Next
Sign up to request clarification or add additional context in comments.

2 Comments

No that is not what I intended. I want to check if array name can be passed as string like ar1(x,y) ar2(x,y) where ar1 ="ar" & i (i coming from iteration.)
No, you cannot do that in VBA.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.