Jun 2, 2011

Clear All Items From Forms Dropdown

 Clear all item in a drop down list in a Form created with Shapes object

Sub FillKeyTopics()

' Clear all item
Sheets("Sheet2").Shapes("dropdownLocation").ControlFormat.ListFillRange = Sheets("Data").Range("A1") ' This code works accidentally find out..
' Sheets("Sheet2").Shapes("dropdownLocation").ControlFormat.ListFillRange = "" ' This code don't work :(

Set RangeNameList = Sheets("Data").Range("D1:G1").Cells

Worksheets("Sheet2").Select

    For Each cell In RangeNameList
        Sheets("Sheet2").Shapes("dropdownLocation").ControlFormat.AddItem cell.Value
    Next cell
   
End Sub

No comments: