Set Command button location

  • Thread starter Thread starter jswalsh33
  • Start date Start date
J

jswalsh33

I would like to be able to set the location of a command button on an Excel
worksheet with macro code. Can that be done?

Thanks for your help,

Jim Walsh
 
Dim myRng As Range
Dim myCmdBtn As OLEObject

Set myRng = Worksheets("Sheet1").Range("c9") '"C9:d10" ???

With myRng
Set myCmdBtn = .Parent.OLEObjects.Add _
(ClassType:="Forms.CommandButton.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=.Left, _
Top:=.Top, _
Width:=.Width, _
Height:=.Height)
End With

myCmdBtn.Object.Caption = "Click Me"
 
Back
Top