Search notes:

Excel Object Model: DropDown

The dropDown object is hidden (like, for example, the Global object).

Creating a DropDown object

sub createDropbox()

    set c = New Class1

    dim rng as range
    set rng = range(range("c3"), range("d3"))
    
    dim drp As DropDown

    set drp = activeSheet.dropDowns.Add(rng.Left, rng.Top, rng.Width, rng.Height)
    
    drp.addItem ("foo")
    drp.addItem ("bar")
    drp.addItem ("baz")
    
    drp.linkedCell = "e5"
        
    drp.name = "chooser"
    drp.onAction = "act"
    
end sub


sub act()

   dim drp as dropDown
   set drp = activeSheet.dropDowns("chooser")
   debug.print "user chose " & drp.list(drp.listIndex) ' Can be abbreviated with drp.list(drp)

end sub

Properties and methods

addItem()
application
bottomRightCell
bringToFront()
caption
characters
copy
copyPicture()
creator
cut
[_Default]
delete()
display3DShading
dropDownLines
duplicate()
enabled
height
index
left
linkedCell A string that contains the address of the cell whose value is updated with the index of the selected item when the user user the drop down.
linkedObject
list An array of variants whose elements correspond to the selectable values in the drop down. list can be written to: drp.list = array("foo", "bar", "baz")
listCount
listFillRange
listIndex
locked
name
onAction A string with the name of the function to be called when the user chooses an item from the drop down. See also some general notes on the onAction property.
parent
placement
printObject
removeAllItems()
removeItem()
select()
selected
sendToBack()
shapeRange
text
top
topLeftCell
value
visible
width
ZOrder

See also

Form controls
Excel Object Model

Index