Select a worksheet based on excel drop down

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
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top