Excel VBA combo box control

I got an issue which my VBA script in excel that i need some expert help here.
The situation is i have 20 combo box added in the excel worksheet which i group as the same category such cboxName1, cboxName2,...cboxName20 because i could not make an array control box. Then I want to write a small routine which i can use loop function to read all the value in these control using a variable to identify the specify combo box ? For example whati like to do is as below but that does not work  :
For i = 1 to maxcnt
 var & i = worksheets(1).comboName & i  ".value"
next i

please help me with my problem Thank you.
LVL 5
netcoolAsked:
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.

StellanRosengrenCommented:
Sub tst()
    Dim i As Integer
   
    For i = 1 To 3
   
        Debug.Print Worksheets(1).OLEObjects("ComboBox" & i).Object.Value
   
    Next i
End Sub
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
StellanRosengrenCommented:
ComboBox is part of the OLEObjects collection. You can use the name of the control to select each item. In my example the comboboxes are named "ComboBox1", "ComboBox2", "ComboBox3". The properties of the control are returned by the Object property of the OLEObject.

Regards,
Stellan
0
RobSampsonCommented:
Stellan, that's perfect!  Then you could something like this, yeah:
    ReDim arrValues(intMaxCnt)
    For intCount = 1 To intMaxCnt
        arrValues(intCount) = Worksheets(1).OLEObjects("ComboBox" & i).Object.Value
    Next
    MsgBox Join(arrValues, vbCrLf)

Regards,

Rob.
0
netcoolAuthor Commented:
It is exactly what i need, thank everyone.
0
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
VB Script

From novice to tech pro — start learning today.