ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using a Macro Button to Move to a Different Cell (https://www.excelbanter.com/excel-programming/391359-using-macro-button-move-different-cell.html)

RJB

Using a Macro Button to Move to a Different Cell
 
I have a form, where, based on what Option Button the user clicks, should
display a different next question.

In other words, if you click "Yes" and then press the "Submit Answer"
button, you should be taken to an area named "Answer_A". If you click "No"
and then press the "Submit" you should be taken to an area named "N".

The "Submit Answer" button is assigned to Macro "Answer_Q1".

I have my option buttons linked to cell J8 - "Yes" is 1, "No" is 2.

Here's Macro "Answer_Q1":

Sub Answer_Q1()
If J8 = 2 Then
Application.Goto reference:="N", Scroll:=True
ElseIf J8 = "1" Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End Sub

When I click the "Submit" button, NOTHING happens. I tried changing the
option buttons to a drop-down box (and appropriately changed the variables in
the macro, natch), and still nothing happens.

Thoughts?

Thanks!

Mike Fogleman

Using a Macro Button to Move to a Different Cell
 
This worked for me:

Sub Answer_Q1()
If Range("J8").Value = 2 Then
Application.Goto reference:="N", Scroll:=True
ElseIf Range("J8").Value = 1 Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End Sub

Mike F
"RJB" wrote in message
...
I have a form, where, based on what Option Button the user clicks, should
display a different next question.

In other words, if you click "Yes" and then press the "Submit Answer"
button, you should be taken to an area named "Answer_A". If you click "No"
and then press the "Submit" you should be taken to an area named "N".

The "Submit Answer" button is assigned to Macro "Answer_Q1".

I have my option buttons linked to cell J8 - "Yes" is 1, "No" is 2.

Here's Macro "Answer_Q1":

Sub Answer_Q1()
If J8 = 2 Then
Application.Goto reference:="N", Scroll:=True
ElseIf J8 = "1" Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End Sub

When I click the "Submit" button, NOTHING happens. I tried changing the
option buttons to a drop-down box (and appropriately changed the variables
in
the macro, natch), and still nothing happens.

Thoughts?

Thanks!




RJB

Using a Macro Button to Move to a Different Cell
 
When I run it. NOTHING happens. No error messages, but no movement either!

"Mike Fogleman" wrote:

This worked for me:

Sub Answer_Q1()
If Range("J8").Value = 2 Then
Application.Goto reference:="N", Scroll:=True
ElseIf Range("J8").Value = 1 Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End Sub

Mike F
"RJB" wrote in message
...
I have a form, where, based on what Option Button the user clicks, should
display a different next question.

In other words, if you click "Yes" and then press the "Submit Answer"
button, you should be taken to an area named "Answer_A". If you click "No"
and then press the "Submit" you should be taken to an area named "N".

The "Submit Answer" button is assigned to Macro "Answer_Q1".

I have my option buttons linked to cell J8 - "Yes" is 1, "No" is 2.

Here's Macro "Answer_Q1":

Sub Answer_Q1()
If J8 = 2 Then
Application.Goto reference:="N", Scroll:=True
ElseIf J8 = "1" Then
Application.Goto reference:="Answer_A", Scroll:=True
End If
End Sub

When I click the "Submit" button, NOTHING happens. I tried changing the
option buttons to a drop-down box (and appropriately changed the variables
in
the macro, natch), and still nothing happens.

Thoughts?

Thanks!





RJB

Using a Macro Button to Move to a Different Cell
 
Scratch that. I started from the beginning, and it works fine.

Hmmm.....

Thanks!


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com