1

I have "ComboBox1" with entries in it. Every time the user selects an entry, the following is triggered:

Private Sub ComboBox1_Change()
    call populate(ComboBox1.ListIndex)
End Sub

The function "populate" has the following:

Sub populate(index as integer)

    dim arr0, arr1, arr2 ...
        arr0 = Array(...)
        arr1 = Array(...)
        arr2 = Array(...)

    Do While x < Application.CountA("arr" + index)
        ...
    Loop

End Sub

I want to make "arr" + index dynamic so it calls the proper array based on the index recevied from the caller function. Can this be done?

2
  • Use an array to hold your arrays... Commented Jul 25, 2015 at 22:33
  • Based on the answer below, what is the syntax to call an element within the dynamic name? Example, arr(index).x where x = 1 Commented Jul 25, 2015 at 22:44

1 Answer 1

2
Sub populate(index as integer)

    dim arr(0 to 2)
        arr(0) = Array(...)
        arr(1) = Array(...)
        arr(2) = Array(...)

    Do While x < Application.CountA(arr(index))
        ...
    Loop

End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

How would you call an element? Example, arr(index).x ??

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.