ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggle Button Caption (https://www.excelbanter.com/excel-programming/395223-toggle-button-caption.html)

5elpep

Toggle Button Caption
 
Hi all,

I have a spin button on my worksheet which controls the
contents of a particular cell. I also have a toggle box on the
same worksheet. I need the caption on the toggle box to change
in real time as the cell changes.

Does anyone have any ideas as to how this might be achieved?

Thanks


Bob Phillips

Toggle Button Caption
 
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value < "" Then
Me.OLEObjects("ToggleButton1").Object.Caption = .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"5elpep" wrote in message
ups.com...
Hi all,

I have a spin button on my worksheet which controls the
contents of a particular cell. I also have a toggle box on the
same worksheet. I need the caption on the toggle box to change
in real time as the cell changes.

Does anyone have any ideas as to how this might be achieved?

Thanks





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

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