excelbuttonactivexobject

Make ActiveX buttons not move with cells / Excel


Have a couple if ActiveX Command Buttons in a worksheet. When I hide some rows, they move with the cells and end up on top of each other. Which property should I use to tell them to just stay put?


Solution

  • Right-click the command button and select Format Control.
    Go to the Properties tab and tick Don't move or size with cells.

    Edit after question accepted as answer
    To do this in VBA use:

    Sub Test()
    
        Dim btn As Object
        Set btn = Sheet1.CommandButton1
        'Or
        'Set btn = Sheet1.OLEObjects("CommandButton1")
        
        btn.Placement = xlFreeFloating
    
    End Sub  
    

    xlFreeFloating (3) - Object is free floating.
    xlMove (2) - Object is moved with the cells.
    xlMoveAndSize (1) - Object is moved and sized with the cells.

    Using ActiveX Controls on Sheets