Creating a Message Box


Posted by Sam on June 19, 2001 9:51 AM

I was wondering how I could create a message box that has the Ok/Cancel format. It tells the user that it will run another macro and if the user clicks Ok it will run that macro. If the person click cancel it will do nothing. Any help is appreciated.

Posted by Jerid on June 19, 2001 10:30 AM

Hi Sam.

Try this

Sub DisplayMessageBox()
Dim iYesNo As Integer

iYesNo = MsgBox("Another Macro will now run", vbYesNo)

If iYesNo = vbYes Then
'Call other Procedure/Macro here
Else
Exit Sub
End If
End Sub

Posted by Sam on June 19, 2001 11:00 AM

iYesNo = MsgBox("Another Macro will now run", vbYesNo) If iYesNo = vbYes Then 'Call other Procedure/Macro here Else Exit Sub End If

Great thank you. Just one question on the line 'Call other Procedure/Macro here' what would I actually put if the macro name is "replace". Also it might be in a different workspace. Thanks again for your help.

Sam



Posted by Jerid on June 20, 2001 5:24 AM

iYesNo = MsgBox("Another Macro will now run", vbYesNo) If iYesNo = vbYes Then 'Call other Procedure/Macro here Else Exit Sub End If

Call replace
As long as it's in the same workbook and it doesn't start with Private Sub. If it does start with private sub change it to Public Sub or just Sub. If it's in a differnt workbook it get more complicated, but it can be done.