Search code examples
excelvbadrop-down-menusetfocus

VBA Excel setfocus on Dropdown box


I am trying to set the focus in Excel through VBA code towards a dropdown box. I have tried various things which bring unwanted results. The item below is the only one I have got to focus on the drop down box but it is selecting the dropdown as if it was selected under developer (with the resizing dots), whereas I just want it to point to the cell if thats possible. I don't want the user to be able to resize the dropdown or anything and its locked so its weird that it would do that.

ActiveSheet.Shapes("DropDown1").Select

Solution

  • Try this

    Sub TestFocus()
        Dim ws As Worksheet
        Dim dd As DropDown
    
        Set ws = ActiveSheet
        Set dd = ws.Shapes("DropDown1").OLEFormat.Object
    
        dd.TopLeftCell.Select
    End Sub