View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RJB RJB is offline
external usenet poster
 
Posts: 86
Default Running code from form button

In other words, write an individual macro for each click?

"FSt1" wrote:

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

"RJB" wrote:

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.