ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set Command button location (https://www.excelbanter.com/excel-programming/433769-set-command-button-location.html)

jswalsh33

Set Command button location
 
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

Dave Peterson

Set Command button location
 
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"



jswalsh33 wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 06:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com