hide/unhide command button

P

Pa Maher

I am developing a quiz template.
After the question is answered I want to display or activate a "Next
Question" command button (affording the test taker the opportunity to review
the answer and explanation of the answer before progressing to the next
question).
After the "Next Question" is presented, the "Next Question" command button
should be hidden or deactivated until the new question is answered correctly.
 
B

Bernie Deitrick

Add a commandbar from the Control Toolbox (NOT the Forms toolbar) and use change event code like
this

'In a regular module
Public CorrectAnswer As Variant

'You'll need code to assign the correct answer to CorrectAnswer

In the worksheet codemodule of your test sheet, use event code like

Private Sub Worksheet_Change(ByVal Target As Range)
'Answer is entered into cell D5
If Target.Address <> "$D$5" Then Exit Sub
If Target.Value = CorrectAnswer Then
Worksheets("Test Sheet").Shapes("CommandButton1").Visible = True
End If
End Sub


and when you change the question, use code like this to hide the button

Worksheets("Test Sheet").Shapes("CommandButton1").Visible = False


HTH,
Bernie
MS Excel MVP
 

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

Similar Threads


Top