Hi,

I've created a dynamic userform that will show a number of comboboxes
indicated by the global variable "HomeGoals". This variable will be
given a variable in the previous userform, which then calls my dynamic
userform.

I've managed to show the number of comboboxes I want, as well as
resize the userform accordingly in the UserForm_Initialize() Sub.

My problem comes when I try to access the contents of these
comboboxes. The user is able to choose a value from the list for each
combobox, but I only need to access these once they click the "Submit"
button. I'm trying to access these comboboxes but I cannot find
anything that refers to them. This is normally done using Me.[name of
the combobox], but it won't work with the comboboxes created in the
Initialize Sub.

Please find below the code I use to create them [in UserForm_Initialize
()]:

    For iHome = 1 To HomeGoals
        Set cboxHomeGS = Me.Controls.Add("Forms.ComboBox.1")
        With cboxHomeGS
            .Name = "cboxHomeGS" & iHome 'Give it a name
            '(...) edit other properties, such as font, top, left etc.
            cboxHomeGS.List = Range("Goal_Scorers").Value  'fill the
list of values to choose from
        End With
    Next iHome


Then when I create the Submit button Sub:

Private Sub Submit_Click()

    MsgBox ("Name 1: ") & Me.cboxHomeGS1.Value

End Sub

I just tried line that to see if I could read the Value, but it gives
me an error: "can't find the method"

Is there a way to access the different objects added to the userform
programmatically?
I'm not sure if "Me.Controls" is the way, I can't find what exactly
this gives me access to. What am I doing wrong?

Thank you very much for your help.

Cheers,
Uli.

--~--~---------~--~----~------------~-------~--~----~
----------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 5,200 subscribers worldwide and receive many nice notes about the 
learning and support from the group. Our goal is to have 10,000 subscribers by 
the end of 2009. Let friends and co-workers know they can subscribe to group at 
http://groups.google.com/group/excel-macros/subscribe
-~----------~----~----~----~------~----~------~--~---

Reply via email to