Running Conditional If-then script off a command box

B

Bucs85027

I am trying to set up a command box that will do two things conditionally if
clicked. First, I want to run script that will validate that text is
present in a range of cells (all cells must have text values, although the
text values may vary). If all of the cells in the range contain text, then
the command button will take the user to the next sheet. If all the cells in
the range do not have text, the command button will spawn a message box
informing the user that all questions must be answered in order to continue.
If anyone can help with this, I would appreciate it! I have been trying to
figure this out for nearly a week!
 
B

Bucs85027

Thank you for responding. I am attempting to create a multi-paged survey
through Excel. Page One contains 7 questions that the user must answer via
Active X Combo Boxes. I linked the combo boxes to cells in the same sheet.
When the user answers a question, the text appears in the linked cells. All
the linked cells are in the same column (S11:S20).
 
J

jhyatt

sorry forgot to add this to the end of the code

Worksheets("sheet2").Range("b4").Activate
 
J

jhyatt

you could something like this just replace the cell value ie b1 with cells
that should contain the text.

Sub AnswerQuestion()
If b1 = "" Then
MsgBox "All questions must be answered"
Worksheets("Sheet1").Range("b1").Activate
ElseIf b4 = "" Then
MsgBox "All questions must be answered"
Worksheets("Sheet1").Range("b4").Activate
End If
End Sub
 
J

jhyatt

this should do the trick

Sub AnswerQuestion()
Worksheets("Sheet1").Range("b1").Activate
If ActiveCell.Value = "" Then
MsgBox "All questions must be answered"
Worksheets("Sheet1").Range("b1").Activate
End If
Worksheets("Sheet1").Range("b4").Activate
If ActiveCell.Value = "" Then
MsgBox "All questions must be answered"
Worksheets("Sheet1").Range("b4").Activate
Else
ActiveWorkbook.Sheets("sheet2").Activate
Worksheets("Sheet2").Range("b1").Activate
End If
End Sub
 

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

Top