Is there a way to "snap" a row or column of command buttons to align the tops or lefts on a worksheet? Even have the ability to get in and modify the left and top properties would work, if possible.
The following procedure should get you started. It aligns every CommandButton on the active worksheet with the top & left edge of the cell it is currently postioned over. To test, create a CommandButton (using the Control Toolbox toolbar) on a worksheet then hold down the Ctrl key while clicking and dragging with the mouse to quickly create several additonal buttons. Move these around to different cells or even in different rows of the same column. Run the procedure.
Code:
Sub AlignButtons()
Dim oBtn As OLEObject
With ActiveSheet
For Each oBtn In .OLEObjects
If InStr(1, oBtn.Name, "CommandButton", vbTextCompare) > 0 Then
oBtn.Top = oBtn.TopLeftCell.Top
oBtn.Left = oBtn.TopLeftCell.Left
End If
Next oBtn
End With
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.