General discussion

Locked

Command button vba part 2

By dcarrier ·
I am just learning excell VBA and on a command button I am putting in MsgBox lines in VB.I also add a no button in the msgbox.What line would I put in to make the msgbox close when you press the no button?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Comments

Collapse -

Command button vba part 2

by Bill_H In reply to Command button vba part 2

The following code will display a succession of message boxes as long as the user clicks on the "Yes" button; if the user clicks on a "No" button, they will be returned to the form containing CommandButton1.

Private Sub Command1_Click()
'This variable indicates which MsgBox button was clicked
Dim iResult As Integer

iResult = MsgBox(Prompt:="test box", Buttons:=4)
If iResult = vbYes Then
iResult = MsgBox("press no to close", Buttons:=4)
If iResult = vbYes Then
iResult = MsgBox("test 3", Buttons:=4)
If iResult = vbYes Then
MsgBox "test 4", Buttons:=4
End If
End If
End If
End Sub

Collapse -

Command button vba part 2

by dcarrier In reply to Command button vba part 2

Poster rated this answer

Collapse -

Command button vba part 2

by dcarrier In reply to Command button vba part 2

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums