Excel - Update ActiveX OptionButton automatically after value change in cell

rzdz

New Member
Joined
Jul 19, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have countless option buttons in a sheet that are always grouped in pairs of two. The option buttons simply pass a value multiplied by the factor from A1 to another cell. Everything works like this... However, when I change the factor in A1, the corresponding value in E231 is not changed automatically. For that, I would first have to click the other button and then the original one again.

The following code of two related option buttons:

Private Sub OptionButton83_Click()
Range("E231").Value = Range("F231").Value * Range("A1").Value
End Sub

Private Sub OptionButton84_Click()
Range("E231").Value = Range("G231").Value * Range("A1").Value
End Sub

Can someone please help me how to automate the Option Buttons in this respect, because there are too many option buttons to keep re-clicking them?

Any help would be greatly appreciated.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you still want to re-click them then

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        Me.OptionButton83.Value = False
        Me.OptionButton84.Value = False
    End If
End Sub

If not then

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        If Me.OptionButton83.Value Then
           Range("E2").Value = Range("F2").Value * Range("A1").Value
        ElseIf Me.OptionButton84.Value Then
            Range("E2").Value = Range("G2").Value * Range("A1").Value
        End If
    End If
End Sub

or
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then
        If Me.OptionButton83.Value Then
            OptionButton83_Click
        ElseIf Me.OptionButton84.Value Then
            OptionButton84_Click
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,883
Messages
6,175,167
Members
452,615
Latest member
bogeys2birdies

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