MrExcel Publishing
Your One Stop for Excel Tips & Solutions

MESSAGEBOX!!! HELP PLEASE!!!


Posted by SLAPERIG on October 09, 2001 11:26 PM

I've got a problem!!!

I want when clicking on a button that a macro will be activated. And I want the macro to do the following things:

- If Range R2:S2 is empty then let a messagebox appear with the question "Are you sure you wanna save without name?" If YES then run "Macro1" and "Macro2" if NO then select Range R2:S2 and exit.

- If Range R2:S2 is NOT empty then it must show a messagebox which says "Are you sure you wanna save and exit?" if YES then run "Macro1" and "Macro2" if NO then exit.

That's it. I don't get it working. The one I've got they save in both ways. When you say YES and also when you say NO so I hope someone can tell me how to do it.

Thanks In Advance

SLAPERIG


Posted by RONALD on October 11, 2001 1:13 AM

Try this:-

Private Sub CommandButton1_Click()
Dim DebNr As Range

Set DebNr = Worksheets("Sheet1").Range("R2")

If DebNr = "" Then
Dim Message, Style1, Title1, Response1
Message = "Are you sure you wanna save without name?"
Style1 = vbYesNo
Title1 = "Save"
Answer1 = MsgBox(Message, Style1, Title1)
If Answer = vbYes Then
Macro1
Macro2
Else
DebNr.Select
Exit Sub
End If
End If
If Not DebNr = "" Then
Dim Msg, Style, Title, Response
Msg = "Are you sure you wanna save and exit?"
Style = vbYesNo
Title = "Save"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Macro1
Macro2
Else
End If
DebNr.Select
End If
End Sub