Set Command button location

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
 
D

Dave Peterson

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top