Running code from form button

G

Guest

I would like to have a form where when a question is asked, if you click the
radio button (er, "Form Toolbox 'Option' button"), you will get different
results based on whether or not you click "Yes" or "No". (Separate buttons -
one for "yes" and one for "no")

I've assigned the Format control cell link to a certain cell, and then
written code referencing the value of that cell.

If I simply TYPE a "1" or a "2" in that cell (cell D8), the code runs fine.
But clicking the radio button (which changes the value of that cell to "1" or
"2") does nothing.

Is there a way to accomplish this?

Here's the code:

==========================
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$8" Then
If Target.Value = "2" Then
Application.Goto reference:="N", Scroll:=True
ElseIf Target.Value = "1" Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End If
==========================

Thanks for the help.
 
G

Guest

hi,
The reason you are having trouble is that you are using the worksheet change
event. this doesn't work on controls, only on the sheet itself. Controls have
their own events, independent from worksheet and workbook events. I suggest
that you move the code to the option button's click or change event. (not
sure which....i didn't test)

good luck
regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top