2

I am having trouble running a macro automatically when I select a radio button option. There are two radio-button options, which are linked to the cell named "SimType" on the sheet codenamed "MAIN". I have adapted the following code from MSDN and have included it in the module for the MAIN worksheet but cannot get it to function:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim KeyCells As Range
    Set KeyCells = Range("SimType")
    If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
       RefreshSimsList 
    End If
End Sub

I understand Target refers to the ActiveCell so when I manually enter values of 1 or 2 into Range("SimType"), the macro triggers. However, when the cell is altered by the linked radio-buttons, no action is triggered. What can I do to have the sheet recognize that the value has been changed without it being the ActiveCell?

1
  • Unfortunally you will not be enable to do this using a form control. To capturing a radiobutton click event you should use an ActiveX control (RadioButton). Commented Apr 4, 2014 at 16:26

1 Answer 1

2

Place this code in a module

Sub OptCommon()
    '
    '~~> Rest of the code
    '
End Sub

And simply right click on both the option button and assign macro to it. Now not only the cell value will change but the macro will also run.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.