levans_1986
New Member
- Joined
- Aug 9, 2017
- Messages
- 13
Hello
I am creating a questionnaire which comprises of three excel worksheets. On the first worksheet one of the questions has a yes/no answer in a dropdown. I want to automatically select a worksheet depending on the answer to the question
For example:
If someone selects yes they are automatically taken to worksheet 2(PartA). If they select no they are automatcially taken to worksheet 3(PartB).
I have recorded two macros, Mac_PartA which takes you to sheet 2 and Mac_PartB which takes you to sheet 3. I've tried to use some vba code but I'm not overly familar with it and I am getting a compile error. the code I have is saved in the workbook rather than the sheet
the code is
Private Sub Workbook_SheetChange(ByVal Target As Range)
If Not Intersect(Target, Range("P2")) Is Nothing Then Select Case Range("P2")
Select Case Range("P2")
Case "Yes": Mac_PartA
Case "No": Mac_PartB
End Select
End If
End Sub
Can anyone help?
Many thanks in advance
Laura
I am creating a questionnaire which comprises of three excel worksheets. On the first worksheet one of the questions has a yes/no answer in a dropdown. I want to automatically select a worksheet depending on the answer to the question
For example:
If someone selects yes they are automatically taken to worksheet 2(PartA). If they select no they are automatcially taken to worksheet 3(PartB).
I have recorded two macros, Mac_PartA which takes you to sheet 2 and Mac_PartB which takes you to sheet 3. I've tried to use some vba code but I'm not overly familar with it and I am getting a compile error. the code I have is saved in the workbook rather than the sheet
the code is
Private Sub Workbook_SheetChange(ByVal Target As Range)
If Not Intersect(Target, Range("P2")) Is Nothing Then Select Case Range("P2")
Select Case Range("P2")
Case "Yes": Mac_PartA
Case "No": Mac_PartB
End Select
End If
End Sub
Can anyone help?
Many thanks in advance
Laura