Macro If statement to go to a specific cell in another worksheet

  • Thread starter Thread starter cailotto
  • Start date Start date
C

cailotto

I have a worksheet that has a column for a Y or N answer. If the user
answers Y, I want a macro to run to jump to the other worksheet. I
need the macro to run for each input of Y going down the worksheet.

So, how do I link a macro to a Y or N answer in a cell, and how do I
make the macro run relative to the cell with the Y answer?

Any help on this is greatly appreciated.
 
You could use a worksheet change event to do this. As an example:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count = 1 And Target.Value = "Y" _
And Target.Column = 1 Then 'change column as required
Sheets(2).Select
End If
End Sub

would select the second sheet every time Y is entered into a cell in
column A.
This is worksheet event code. Right click the sheet tab, select view
code and paste the event in there.

For more on events see:

http://www.cpearson.com/excel/events.htm

Hope this helps
Rowan
 

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

Back
Top