Clearing list from all form commandboxes

  • Thread starter Thread starter josh ashcraft
  • Start date Start date
J

josh ashcraft

attn: Tom Oglivy or anyone else who may be able to help...

I need help Clearing the list from all form commandboxes
on my worksheet, the code I had earlier didn't seem to
work correctly, or I was using it wrong, could someone
please help me with this?
Thanks in advance,
Josh
 
Hi Josh:

What is a "commandbox"?

If you mean ComboBoxes:

Sheet1.ComboBox1.Clear
Sheet1.ComboBox2.Clear

etc.

You cannot clear ComboBoxes in this fashion if they are populated via a
RowSource.

Regards,

Vasant.
 
Some more:

These all worked for comboboxes (dropdowns) from the Forms Toolbar:

Sub ClearListFill()
Dim drp As DropDown
For Each drp In ActiveSheet.DropDowns
drp.ListFillRange = ""
Next
End Sub

Sub Populate()
Dim drp As DropDown
For Each drp In ActiveSheet.DropDowns
drp.RemoveAllItems
drp.AddItem "1st"
drp.AddItem "2nd"
drp.AddItem "3rd"
drp.AddItem "4th"
drp.AddItem "5th"
Next

End Sub
Sub ClearDropDown()
'clear list set with listfillrange or additem
Dim drp As DropDown
For Each drp In ActiveSheet.DropDowns
drp.RemoveAllItems
Next

End Sub

Sub SetListFill()
Dim drp As DropDown
For Each drp In ActiveSheet.DropDowns
drp.ListFillRange = ActiveSheet. _
Range("A1:A10").Address(external:=True)
Next

End Sub
 
Back
Top