HL8
HL8

Reputation: 1419

excel vba - msgbox yes/no reply

I'm validating users input in userform. I have a msgbox prompt, with yesNo.

If yes is clicked then just continue, if no is clicked I want the user to be able to go back to the userform to change the input/selection.

The code I've used is

 iReply = MsgBox(Prompt:="You have selected a month which is not next month. Do you want to continue? ", _
     Buttons:=vbYesNo, Title:="")
     If iReply = vbNo Then
        UserForm.Show
     End If

I get an error for "form already displayed cannot show modally" for UserForm.Show

Upvotes: 1

Views: 11462

Answers (1)

Derek
Derek

Reputation: 142

The UserForm must be unloaded or hidden before it's loaded again. Try unloading using:

Unload UserForm

or hide it using

UserForm.Hide

Upvotes: 2

Related Questions