ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change 'Caption' on ToggleButtons with VBA (https://www.excelbanter.com/excel-programming/386197-re-change-caption-togglebuttons-vba.html)

Jay

Change 'Caption' on ToggleButtons with VBA
 
Thanks a bunch, Greg. The Object property of the OleObjects collection was
what I was missing. Your procedure worked perfectly and I'll be using this a
lot in the near future.

--
Thanks again,
Jay


"Greg Wilson" wrote:

Try:

Sub addToggles()
Dim i As Integer
For i = 0 To 1
With ActiveSheet.OLEObjects.Add("Forms.ToggleButton.1", _
Left:=1 + i * 73, Top:=243, Width:=72, Height:=30.75)
.Object.Caption = IIf(i = 0, "Start Date", "End Date")
End With
Next
End Sub

Regards,
Greg




Greg Wilson

Change 'Caption' on ToggleButtons with VBA
 
You're welcome. Thanks for the feedback.

Greg

"Jay" wrote:

Thanks a bunch, Greg. The Object property of the OleObjects collection was
what I was missing. Your procedure worked perfectly and I'll be using this a
lot in the near future.

--
Thanks again,
Jay


"Greg Wilson" wrote:

Try:

Sub addToggles()
Dim i As Integer
For i = 0 To 1
With ActiveSheet.OLEObjects.Add("Forms.ToggleButton.1", _
Left:=1 + i * 73, Top:=243, Width:=72, Height:=30.75)
.Object.Caption = IIf(i = 0, "Start Date", "End Date")
End With
Next
End Sub

Regards,
Greg





All times are GMT +1. The time now is 10:55 PM.

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