I am trying to write a code that directs the user to a specific sheet in the workbook depending on a yes or no answer.
So basically there is information that will need to be completed and the information is specific to whether it is a YES or NO. So I want to set up a page where one of the questions is a yes/no question and depending on the answer you will be directed to a specific sheet for data input. With in that sheet there will be drop down lists specific to that sheet. Data that is based on the YES or NO question.

Recommended Answers

All 3 Replies

When you say "sheet" do you mean an Excel sheet?

You can start your code any way you please
In this example I have used the Workbook_SheetChange event in the Workbook code module. This event can be triggered by changing a specific cell in a specified sheet.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim RetVal As Integer
    RetVal = MsgBox("Do You Want To View The Sheet?", vbYesNo, "Get User Response")
    If RetVal = vbYes Then Sheet2.Select
End Sub

A variation on my previous post if you want the "Yes" to occur in a particular cell, in this case A1

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


    If Sh.Name = "Sheet1" _
        And Target.Address = "$A$1" _
        And UCase(Target) = "YES" Then _
        Sheet2.Select

End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.