msgbox question

  • Thread starter Thread starter Wu
  • Start date Start date
W

Wu

In my marco, I want to show a message box to ask " do you have open the
1244.xls file" and to show two button " yes" and "no" for user select.

If user select "yes", my marco will go on,

select "no", it will quit the marco
 
Hi,

You only need to check the No button

response = MsgBox("Have you opened 1244.xls?", vbYesNo, "Your Title")
If response = vbNo Then Exit Sub

Mike
 
Hi,

You may want to consider another method that doesn't rely on the user who
could prees the wrong button. This checks if the workbook is open and exits
the sub if it isn't.

Sub marine()
fname = "1244.xls"
On Error Resume Next
Workbooks(fname).Activate
If Err <> 0 Then
MsgBox "You must have workbook " & fname & " open to continue.
Exiting"
Exit Sub 'Workbook isn't open
End If
Err.Clear 'Clear errors
End Sub

Mike
 

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

Back
Top