I am using excel 2010.
I want to clear the content of a combo box in my sheet(clear to blank like when it’s not selected), but I don’t know how to select and clear. I tried to select a combo box like this:
But no ‘ComboBox’ is under the Sheet1 object. The only to select my combo box is use this:
Sheet1.Shapes("Drop Down 24")
I don’t know how to select and clear the content, can anyone help me?
ActiveSheet.Shapes.Range(Array("Drop Down 24")).Select With Selection .ListFillRange = "" End With
I assume you actually want to make the displayed value of your control blank. In that case, for a Drop Down Object, as you indicated you would do this:
Sheet1.Shapes("Drop Down 2").OLEFormat.Object.Value = 0
Where 0 indicates which element from the list is selected I.E. none.
If that doesn’t work, then you’re probably actually dealing with a ComboBox in which case you want to use this:
Sheet1.Shapes("Drop Down 2").OLEFormat.Object.Object.Value = ""
Note this code was created and tested in Excel 2003 (what I have on this machine) so the path to reaching the actual object might vary slightly on Excel 2010.)
As an autentic programmer I would rather prefer this way. That don’t depends on excel “range memory selection” on the sheet.
Set oCombo = Sheets("SheetName").Shapes("cmbComboName").ControlFormat For I = oCombo.ListCount To 1 Step -1 oCombo.RemoveItem (I) Next
To reset a Drop Down List to a blank cell but still maintaining the list for future use.
Create a Macro to clear the cells. During recording simply select the cell and select “clear contents”. This will set the selection to a blank cell but still keeps the drop down list in place.
It would look like this for example.