ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   msgbox question (https://www.excelbanter.com/excel-discussion-misc-queries/209591-msgbox-question.html)

Wu

msgbox question
 
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


Mike H

msgbox question
 
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

"Wu" wrote:

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


Mike H

msgbox question
 
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

"Mike H" wrote:

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

"Wu" wrote:

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



All times are GMT +1. The time now is 04:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com