VBA options and warning triangle

VictorH

New Member
Joined
Jan 8, 2017
Messages
2
Hi, I have created a text message box and want to add a warning triangle to highlight the message. I tried vbExclamation but this does not work. (Nothing is added to my message) How to add the triangle please? In message box I also wanted to use the option vbYesNoCancel but this didn't work either. The box pops up correctly but clicking 'Yes' doesn't work. Seems vbOKCancel is the only option available to me. Is this correct?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the forum.

Try:

Code:
    x = MsgBox("Do you want to continue?", vbYesNoCancel + vbExclamation, "Question")
 
Last edited:
Upvote 0
Hi Try this

Adapted from VBA helpfile

Code:
Sub MsgBoxExample()
    Dim Msg, Style, Title, Response As VbMsgBoxResult

    Msg = "Do you want to continue ?"                                          ' Define message.
    Style = vbYesNoCancel + vbExclamation + vbDefaultButton2        ' Define buttons.
    Title = "MsgBox Demonstration"                                              ' Define title.
    
'display msgbox
    Response = MsgBox(Msg, Style, Title)
'process response
    If Response = vbYes Then
'Yes Button Pressed
'do something

    ElseIf Response = vbNo Then
'No Button Pressed
'do something

    Else
'Cancel Button Pressed
'do something
        
    End If
End Sub


You can read more about MsgBox Function in VBA helpfile.

Dave
 
Last edited:
Upvote 0
If you want vbExclamation

Use this:
Code:
MsgBox("Hello", vbExclamation)

If you want Yes No Cancel
Use this:

Code:
Sub My_Message()
Dim ans As String
ans = MsgBox("Hello", vbYesNoCancel)
If ans = vbYes Then MsgBox ("You clicked Yes")
If ans = vbNo Then MsgBox ("You clicked No")
If ans = vbCancel Then MsgBox ("You clicked Cancel")
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top