0

Ok, I think this should be a much more simple question: I am working within a userform, and I need to get the value of any and all comboboxes on that userform.

Note that none of the dropdown list values in the comboboxes have come from an excel spreadsheet (the only examples I have seen always reference cells in a sheet, but my values are added at runtime, so these are no good for a n00b like me to understand).

I have this as far as code:

Dim con As Controls
Dim ArrValUe
Dim i

For Each con In Me.Controls
i = 1
    If TypeName(con) = "ComboBox" Then
        If con.Name = "MemberSectionList" & i Then
        ArrValUe = IsInArray(Me.Controls(con).Text, AISC_Manual_Label)
        MsgBox con & " corresponds to AISC_Manual_Label: " & ArrValUe
        Else
        MsgBox "This control name was not named MemberSectionList & i: " & con.Name
        End If
        Else
        MsgBox " I cannot find a control with TypeName = 'Combobox', Dave!"
    End If
i = i + 1
Next

Thanks in advance for any help!

Community
  • 1
  • 1

1 Answers1

0

Nevermind; I got it:

Private Sub Draw_Member_Shapes()

Dim con As Control
Dim ArrValUe
Dim i

For Each con In Me.Controls
i = 1
    If TypeName(con) = "ComboBox" Then
        If con.Name = "MemberSectionList" & i Then
        ArrValUe = IsInArray(con.value, AISC_Manual_Label)
        MsgBox con & " corresponds to AISC_Manual_Label: " & ArrValUe
        End If
    End If
i = i + 1
Next

End Sub

A few notes based on what I figured out:

  • The combobox I needed to find ("MemberSectionList" & i) had previously been generated in another sub, as a OBJECT, not CONTROL
  • IsInArray() came from another user on this forum, JimmyPena, from here: How to search for string in an array ...with some minor tweaking on my end, so props to him for a solid answer...
Community
  • 1
  • 1