Retrieving Combobox Value

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
I'm working on a userform with a combobox styled as a drop down combo. I am filling this combobox with values upon UserForm_Initialize. I want the user to be able to make a selection from the dropdown or enter their own value. The problem I am having is when a user enters their own value I am unable to assign it to a variable. Does anyone know a workaround for this? retrieving

BoundColumn = 1 ColumnCount = 2
Code:
Dim myDiagName As String
Dim myDiagID As Integer

With Me.diagList
    If .ListIndex < 0 Then
        myDiagName = .List(-1, 1)
    Else
        myDiagID = .List(.ListIndex, 0)
        myDiagName = .List(.ListIndex, 1)
    End If
End With
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Nevermind

This works:
Code:
Dim myDiagName As String Dim myDiagID As Integer  With Me.diagList     If .ListIndex < 0 Then         myDiagName = .Text '////////changeg this to .text and works fine     Else         myDiagID = .List(.ListIndex, 0)         myDiagName = .List(.ListIndex, 1)     End If End With</pre>
 
Upvote 0
I'm working on a userform with a combobox styled as a drop down combo. I am filling this combobox with values upon UserForm_Initialize. I want the user to be able to make a selection from the dropdown or enter their own value. The problem I am having is when a user enters their own value I am unable to assign it to a variable. Does anyone know a workaround for this? retrieving

BoundColumn = 1 ColumnCount = 2
Code:
Dim myDiagName As String
Dim myDiagID As Integer

With Me.diagList
    If .ListIndex < 0 Then
        myDiagName = .List(-1, 1)
    Else
        myDiagID = .List(.ListIndex, 0)
        myDiagName = .List(.ListIndex, 1)
    End If
End With

You do not need to use List and ListIndex, just use the Value property...

Code:
myDiagName = diagList.Value
 
Upvote 0

Forum statistics

Threads
1,216,743
Messages
6,132,462
Members
449,729
Latest member
davelevnt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top