VBA to clear ComboBoxes in userform

HUNTING101

New Member
Joined
Jan 7, 2007
Messages
3
Trying to teach myself VBA so please be kind. I have a command button that I want to clear just the data shown in the user form.
This is the code that I have. All of the other data clears properly with the exception of the comboboxes.
Any help is appreciated.

Thanks in advance,
Matt

Code:
Private Sub CommandButton10_Click()

Dim oneControl As Object
For Each oneControl In Form_Daily.Controls
   Select Case TypeName(oneControl)
    
        Case "TextBox"
            oneControl.Text = NullString
        Case "Combobox"
            oneControl.Value = ""
        Case "CheckBox"
            oneControl.Value = False
            
    End Select
    
Next oneControl

End Sub
I have also tried
Case "Combobox"
oneControl.Value = -1

Case "Combobox"
oneControl.Value = Null

Case "Combobox"
oneControl.Value = NullString

Case "Combobox"
oneControl.Value = vbNullString
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
The comparison within Select Case is case-sensitive...

Code:
[COLOR=#333333]Case "Combo[B]B[/B]ox"[/COLOR]

Hope this helps!
 
Last edited:
Upvote 0
You clear a Combobox and a Listbox by using this:

Combobox1.Clear
Listbox1.Clear
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

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