VBA to Enable/Disable Toggle Button

Scuba94

New Member
Joined
Oct 11, 2023
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a working toggle button (names 'RevealCharges') that may or may not be used by the user i.e. sometimes its on, sometimes the user doesn't select it, if its selected it unhides certain rows of data.
I also have another field in excel (named 'CFS_or_CY_Loading') that has a drop down list with 2 options, for simplicity, lets say its 'On' & 'Off' as the 2 options

What I would like to do is, if the toggle button is 'On' and named field 'CFS_or_CY_Loading' is change from 'On' to 'Off', then toggle button 'RevealCharges' is forced to a 'False' status, which means the certain rows are hidden again.

Bassically what I have is , if the Toggle button is 'On' then it is stopping other VBA rules from running, until such time as its tuned 'Off', hence the above question.

I woudl be most appreactive if anyone can offer any help/guidance?

Regards
Richard
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Paste in the SHEET module :

VBA Code:
Option Explicit

Sub ToggleButton1_Click()

With Me.ToggleButton1
If .Value = False Then
   .Caption = "OFF"
   'Your OFF code here
Else: .Caption = "ON"
    'Your ON code here
End If
End With

Sheets("Sheet1").Range("A1").Value = Me.ToggleButton1.Caption
End Sub
 
Upvote 0
Solution
Paste in the SHEET module :

VBA Code:
Option Explicit

Sub ToggleButton1_Click()

With Me.ToggleButton1
If .Value = False Then
   .Caption = "OFF"
   'Your OFF code here
Else: .Caption = "ON"
    'Your ON code here
End If
End With

Sheets("Sheet1").Range("A1").Value = Me.ToggleButton1.Caption
End Sub
thank you :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top