Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox suppression Excel 2010 2

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Good morning, I'm wondering if there's a 'smart' way of determining whether or not to display a message box. My user wants to send the workbook to her colleague so that a message is displayed when a certain country is selected. This is the code I have, but wonder if the two stages could be included in one message?

Code:
        If Range("SelectMarket") = "That Country" Then
        
            If Sheets("Ref").Range("A1") = "0" Then 'Message will be displayed

    MsgBox "Note:  " & vbCrLf & vbCrLf & _
    "From July  onwards, city coverage has been changed to whatever." & vbCrLf & vbCrLf & _
    "To enhance data comparison, backdata from August (FY12) through June (FY13) has been re-run to exclude x and y.  As such, please note that actual results may differ from previous versions."
    
    ''        End If
        
            AreYouSure = MsgBox("Do you want to suppress the previous message?", vbYesNo)
    
                    If AreYouSure = "6" Then
                    myPassword = "xyz"
            
                    Sheets("Ref").Unprotect Password:=myPassword
                    Sheets("Ref").Range("A1") = "1"
                    Sheets("Ref").Protect Password:=myPassword
                
                    End If
            End If
        End If

I hope that makes sense.

Many thanks,
D€$
 
hi,

How about something like this?
Code:
[b]
   Dim Msg As String[/b]
'...[b]
            Msg = [/b]"Note:  " & vbCrLf & vbCrLf & _
            "From July  onwards, city coverage has been changed to whatever." & vbCrLf & vbCrLf & _
            "To enhance data comparison, backdata from August (FY12) through June (FY13) has been re-run to exclude x and y.  As such, please note that actual results may differ from previous versions."
            
            AreYouSure = MsgBox([b]Msg & vbLf & [/b]"Do you want to suppress the previous message?", vbYesNo)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Also, you don't need to use 'AreYouSure' variable.

You can do:

Code:
If vbYes = MsgBox(Msg & vbLf & "Do you want to suppress the previous message?", vbYesNo) Then
...
End If

It is easier to read (in my book).
But that's a personal preference. :)

Have fun.

---- Andy
 
Thanks both. This is what I've ended up with:-

Code:
Dim Msg As String
Msg = "Note:  " & vbCrLf & vbCrLf & _
            "From July  onwards, city coverage has been changed to whatever." & vbCrLf & vbCrLf & _
            "To enhance data comparison, backdata from August (FY12) through June (FY13) has been re-run to exclude x and y.  As such, please note that actual results may differ from previous versions." & vbCrLf
            
    If vbYes = MsgBox(Msg & vbLf & "Do you want to stop this message from appearing again?", vbYesNo) Then

Absolutely brilliant!! :)

Many thanks,
D€$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top