want Option/Radio button to trigger VBA event

Goldfield

New Member
Joined
Oct 29, 2008
Messages
48
I have two radio/option boxes linked to a cell e.g. A1
When I click the different option boxes the values changes (0, 1 or 2)

I want to trigger an event when the value in A1 changes (when an option is selected)

I have tried
_______________
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$1" Then
Me.Range("$C$1") = "The event was triggered"
End If

End sub
_______________
Clicking the option box does not trigger the event, if I go to cell A1 and manually type 1, the equivalent of selecting option box 1 the event triggers just fine, but not if I just click the button)

How can I work around this???
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
You could try using a spare cell (possibly out of the normal view) containing the simple formula =A1 and the code

Code:
Private Sub Worksheet_Calculate()
Me.Range("$C$1") = "The event was triggered"
End Sub

However, this will fire whenever there is a recalculation so if you have other formulas on the sheet this method would be non-specific.

As an alternative consider Data Validation using a list - see http://www.contextures.com/xlDataVal01.html#Dropdown - this event will trigger your original code.
 
Upvote 0
Thanx for the reply

I needed something a specific though since it is part of a big spreadshheet.
I finally gruped the different optionboxes and added a macro when clicking on the group which did the trick.
 
Upvote 0

Forum statistics

Threads
1,223,157
Messages
6,170,418
Members
452,325
Latest member
BlahQz

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