VBA Strings and Arrays

I have an array A(10) which I want to control using a combobox but can not get it to work

for i = 0 to unbound(combobox1,value) .... I need this loop to run when the user select A from the drop down

Cheers
borris111698Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcdown75Commented:
Try this

dim i as integer
For i = 0 to upperbound(A)
    myComboBox.additem(a(i))
Next
myCombo.index = 0

This should loop through your array and add each item to your combo box.
0
borris111698Author Commented:
Cheers Mcdown but I already have a 2 column dropdown (combobox1) populated from an array Section(), the 1st Column has letters A-N the second a description. When the user selects an item I want to populate a sub 2 column dropdown (combobox2) from the arrays A(5), B(6), C(7), D(8)...... etc

I have been able to this using select case, but thought I could do it more simply by using

for i = 0 to unbound(combobox1.value)

therefore if the user selects B from the first dropdown the second in populated with 7 items from the array..
0
GrahamSkanRetiredCommented:
Are you saying that the letters A to N are the names of 14 arrays and that you need to populate your second combo with the one whose name is selected in the first combo?
0
mcdown75Commented:
Ok, if that is the case then you would

sub popBox(byval myarray(9) as array)
dim i as integer
for i = 0 to upperbound(myarray)
mycombo.additem(myarray(i))
next
mycombo.index=0
end sub

Pass your array in based on the value that they select and run the loop
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.