{"id":26412,"date":"2018-07-27T17:56:30","date_gmt":"2018-07-27T12:26:30","guid":{"rendered":"https:\/\/trumpexcel.com\/?p=26412"},"modified":"2026-03-28T08:33:21","modified_gmt":"2026-03-28T03:03:21","slug":"vba-msgbox","status":"publish","type":"post","link":"https:\/\/trumpexcel.com\/vba-msgbox\/","title":{"rendered":"Excel VBA MsgBox [Message Box] &#8211; All You Need to Know!"},"content":{"rendered":"<p>In Excel VBA, you can use the MsgBox function to display a message box (as shown below):<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-26413 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default.png\" alt=\"Default message in a VBA Msgbox\" width=\"206\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default.png 206w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-50x45.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-111x100.png 111w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-166x150.png 166w\" sizes=\"(max-width: 206px) 100vw, 206px\" \/><\/p>\n<p>A MsgBox is nothing but a dialog box that you can use to inform your users by showing a custom message or get some basic inputs (such as Yes\/No or OK\/Cancel).<\/p>\n<p>While the MsgBox dialog box is displayed, your VBA code is halted. You need to click any of the buttons in the MsgBox to run the remaining VBA code.<\/p>\n<div class=\"cbyellow\">Note: In this tutorial, I will be using the words message box and MsgBox interchangeably. When working with Excel VBA, you always need to use <strong>MsgBox<\/strong>.<\/div>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">This Tutorial Covers:<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Anatomy-of-a-VBA-MsgBox-in-Excel\">Anatomy of a VBA MsgBox in Excel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Syntax-of-the-VBA-MsgBox-Function\">Syntax of the VBA MsgBox Function<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Excel-VBA-MsgBox-Button-Constants-Examples\">Excel VBA MsgBox Button Constants (Examples)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Excel-VBA-MsgBox-Icon-Constants-Examples\">Excel VBA MsgBox Icon Constants (Examples)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Customizing-Title-and-Prompt-in-the-MsgBox\">Customizing Title and Prompt in the MsgBox<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#Assigning-MsgBox-Value-to-a-Variable\">Assigning MsgBox Value to a Variable<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2><span class=\"ez-toc-section\" id=\"Anatomy-of-a-VBA-MsgBox-in-Excel\"><\/span>Anatomy of a VBA MsgBox in Excel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A message box has the following parts:<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-26415 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox.png\" alt=\"Anatomy of an VBA Msgbox dialog box\" width=\"268\" height=\"210\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox-50x39.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox-250x196.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox-128x100.png 128w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox-255x200.png 255w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Anatomy-of-an-Excel-VBA-Msgbox-191x150.png 191w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<ol>\n<li><strong>Title<\/strong>: This is typically used to display what the message box is about. If you don&#8217;t specify anything, it displays the application name &#8211; which is Microsoft Excel in this case.<\/li>\n<li><strong>Prompt<\/strong>: This is the message that you want to display. You can use this space to write a couple of lines or even display tables\/data here.<\/li>\n<li><strong>Button(s)<\/strong>: While OK is the default button, you can customize it to show buttons such as Yes\/No, Yes\/No\/Cancel, Retry\/Ignore, etc.<\/li>\n<li><strong>Close Icon<\/strong>: You can close the message box by clicking on the close icon.<\/li>\n<\/ol>\n<h2><span class=\"ez-toc-section\" id=\"Syntax-of-the-VBA-MsgBox-Function\"><\/span>Syntax of the VBA MsgBox Function<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As I mentioned, MsgBox is a function and\u00a0has a syntax similar to other VBA functions.<\/p>\n<p><strong><em>MsgBox( prompt [, buttons ] [, title ] [, helpfile, context ] )<\/em><\/strong><\/p>\n<ul>\n<li><strong>prompt<\/strong> &#8211; This is a required argument. It displays the message that you see in the MsgBox. In our example, the text &#8220;This is a sample MsgBox&#8221; is the &#8216;prompt&#8217;. You can use up to 1024 characters in the prompt, and can also use it to display the values of variables. In case you want to show a prompt that has multiple lines, you can do that as well (more on this later in this tutorial).<\/li>\n<li><strong>[buttons]<\/strong> &#8211; It determines what buttons and icons are displayed in the MsgBox. For example, if I use vbOkOnly, it will show only the OK button, and if I use vbOKCancel, it will show both the OK and Cancel buttons. I will cover different kinds of buttons later in this tutorial.<\/li>\n<li><strong>[title]<\/strong> &#8211; Here you can specify what caption you want in the message dialog box. This is displayed in the title bar of the MsgBox. If you don&#8217;t specify anything, it will show the name of the application.<\/li>\n<li><strong>[helpfile]<\/strong> &#8211; You can specify a help file that can be accessed when a user clicks on the Help button. The help button would appear only when you use the button code for it. If you&#8217;re using a help file, you also need to also specify the context argument.<\/li>\n<li><strong>[context]<\/strong> &#8211; It is a numeric expression that is the Help context number assigned to the appropriate Help topic.<\/li>\n<\/ul>\n<p>If you&#8217;re new to the concept of Msgbox, feel free to ignore the [helpfile] and [context] arguments. I have rarely seen these being used.<\/p>\n<p>Note: All the arguments in square brackets are optional. Only the &#8216;prompt&#8217; argument is mandatory.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Excel-VBA-MsgBox-Button-Constants-Examples\"><\/span>Excel VBA MsgBox Button Constants (Examples)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this section, I will cover the different types of buttons that you can use with a VBA MsgBox.<\/p>\n<p>Before I show you the VBA code for it and how the MsgBox looks, here is a table that lists all the different button constants you can use.<\/p>\n<table style=\"height: 495px;\" width=\"963\">\n<tbody>\n<tr>\n<td width=\"127\"><strong>Button Constant<\/strong><\/td>\n<td width=\"64\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>vbOKOnly<\/td>\n<td>Shows only the OK button<\/td>\n<\/tr>\n<tr>\n<td>vbOKCancel<\/td>\n<td>Shows the OK and Cancel buttons<\/td>\n<\/tr>\n<tr>\n<td>vbAbortRetryIgnore<\/td>\n<td>Shows the Abort, Retry, and Ignore buttons<\/td>\n<\/tr>\n<tr>\n<td>vbYesNo<\/td>\n<td>Shows the Yes and No buttons<\/td>\n<\/tr>\n<tr>\n<td>vbYesNoCancel<\/td>\n<td>Shows the Yes, No, and Cancel buttons<\/td>\n<\/tr>\n<tr>\n<td>vbRetryCancel<\/td>\n<td>Shows the Retry and Cancel buttons<\/td>\n<\/tr>\n<tr>\n<td>vbMsgBoxHelpButton<\/td>\n<td>Shows the Help button. For this to work, you need to use the help and context arguments in the MsgBox function<\/td>\n<\/tr>\n<tr>\n<td>vbDefaultButton1<\/td>\n<td>Makes the first button default. You can change the number to change the default button. For example, vbDefaultButton2 makes the second button as the default<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"color: #333333;\">Note: While going through the examples of creating different buttons, you may wonder what&#8217;s the point of having these buttons if it doesn&#8217;t have any impact on the code. <\/span><\/p>\n<p><span style=\"color: #333333;\">It does! Based on the selection, you can code what you want the code to do. For example, if you select OK, the code should continue, and if you click Cancel, the code should stop. This can be done by using variables and assigning the value of the Message Box to a variable. We will cover this in the later sections of this tutorial.<\/span><\/p>\n<p>Now let&#8217;s have a look at some examples of how the different buttons can be displayed in a MsgBox and how it looks.<\/p>\n<h3>MsgBox Buttons &#8211; vbOKOnly (Default)<\/h3>\n<p>If you only use the prompt and don&#8217;t specify any of the arguments, you will get the default message box as shown below:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-26413 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default.png\" alt=\"Sample message box\" width=\"206\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default.png 206w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-50x45.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-111x100.png 111w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Sample-Default-166x150.png 166w\" sizes=\"(max-width: 206px) 100vw, 206px\" \/><\/p>\n<p>Below is the code that will give this message box:<\/p>\n<pre>Sub DefaultMsgBox()\nMsgBox \"This is a sample box\"\nEnd Sub<\/pre>\n<p>Note that the text string needs to be in double quotes.<\/p>\n<p>You can also use the button constant\u00a0vbOKOnly, but even if you don&#8217;t specify anything, it&#8217;s taken as default.<\/p>\n<h3>MsgBox Buttons &#8211; OK &amp; Cancel<\/h3>\n<p>If you only want to show the OK and the Cancel button, you need to use the vbOKCancel constant.<\/p>\n<pre>Sub MsgBoxOKCancel()\nMsgBox \"Want to Continue?\", vbOKCancel\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26422 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel.png\" alt=\"ok and cancel buttons in a message box\" width=\"268\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel-50x35.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel-250x174.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel-144x100.png 144w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-ok-and-cancel-216x150.png 216w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Buttons &#8211; Abort, Retry, and Ignore<\/h3>\n<p>You can use the &#8216;vbAbortRetryIgnore&#8217; constant to show the Abort, Retry, and the Ignore buttons.<\/p>\n<pre>Sub MsgBoxAbortRetryIgnore()\nMsgBox \"What do you want to do?\", vbAbortRetryIgnore\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26428 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel.png\" alt=\"Excel VBA Msgbox - Abort Retry and Cancel buttons\" width=\"378\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel.png 378w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel-50x25.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel-250x123.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel-203x100.png 203w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Abort-Retry-Cancel-305x150.png 305w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><\/p>\n<h3>MsgBox Buttons &#8211; Yes and No<\/h3>\n<p>You can use the &#8216;vbYesNo&#8217; constant to show the Yes and No buttons.<\/p>\n<pre>Sub MsgBoxYesNo()\nMsgBox \"Should we stop?\", vbYesNo\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26429 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No.png\" alt=\"Yes and No buttons in a message box\" width=\"268\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-50x35.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-250x174.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-144x100.png 144w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-216x150.png 216w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Buttons &#8211; Yes, No and Cancel<\/h3>\n<p>You can use the &#8216;vbYesNoCancel&#8217; constant to show the Yes, No, and Cancel buttons.<\/p>\n<pre>Sub MsgBoxYesNoCancel()\nMsgBox \"Should we stop?\", vbYesNoCancel\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26430 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel.png\" alt=\"Excel VBA Message Box- Yes and No and Cancel\" width=\"378\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel.png 378w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel-50x25.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel-250x123.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel-203x100.png 203w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-and-No-and-Cancel-305x150.png 305w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><\/p>\n<h3>MsgBox Buttons &#8211; Retry and Cancel<\/h3>\n<p>You can use the &#8216;vbRetryCancel&#8217; constant to show the Retry and Cancel buttons.<\/p>\n<pre>Sub MsgBoxRetryCancel()\nMsgBox \"What do you want to do next?\", vbRetryCancel\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26431 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel.png\" alt=\"Retry and Cancel buttons\" width=\"268\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel-50x35.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel-250x174.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel-144x100.png 144w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Messagebox-Retry-and-Cancel-216x150.png 216w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Buttons &#8211; Help Button<\/h3>\n<p>You can use the &#8216;vbMsgBoxHelpButton&#8217; constant to show the help button. You can use it with other button constants.<\/p>\n<pre>Sub MsgBoxRetryHelp()\nMsgBox \"What do you want to do next?\", vbRetryCancel + vbMsgBoxHelpButton\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26432 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button.png\" alt=\"help button in the message box dialog box\" width=\"378\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button.png 378w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button-50x25.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button-250x123.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button-203x100.png 203w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-help-button-305x150.png 305w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><\/p>\n<p>Note that in this code, we have combined two different button constants (<strong>vbRetryCancel + vbMsgBoxHelpButton<\/strong>). The first part shows the Retry and Cancel buttons and the second part shows the Help button.<\/p>\n<h3>MsgBox Buttons &#8211; Setting a Default Button<\/h3>\n<p>You can use the &#8216;vbDefaultButton1&#8217; constant to set the first button as default. This means that the button is already selected and if you press enter, it executes that button.<\/p>\n<p>Below is the code that will set the second button (the &#8216;No&#8217; button) as the default.<\/p>\n<pre>Sub MsgBoxOKCancel()\nMsgBox \"What do you want to do next?\", vbYesNoCancel + vbDefaultButton2\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26434 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2.png\" alt=\"by default, second button is selected\" width=\"378\" height=\"186\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2.png 378w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2-50x25.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2-250x123.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2-203x100.png 203w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-default-button-2-305x150.png 305w\" sizes=\"(max-width: 378px) 100vw, 378px\" \/><\/p>\n<p>In most cases, the left-most button is the default button. You can choose other buttons using\u00a0vbDefaultButton2,\u00a0vbDefaultButton3, and\u00a0vbDefaultButton4.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Excel-VBA-MsgBox-Icon-Constants-Examples\"><\/span>Excel VBA MsgBox Icon Constants (Examples)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Apart from the buttons, you can\u00a0also customize the icons that are displayed in the MsgBox dialog box. For example, you can have a red critical icon or a blue information icon.<\/p>\n<p>Below is a table that lists the code that will show the corresponding icon.<\/p>\n<table style=\"height: 187px;\" width=\"978\">\n<tbody>\n<tr>\n<td width=\"127\"><strong>Icon Constant<\/strong><\/td>\n<td width=\"64\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td>vbCritical<\/td>\n<td>Shows the critical message icon<\/td>\n<\/tr>\n<tr>\n<td>vbQuestion<\/td>\n<td>Shows the question icon<\/td>\n<\/tr>\n<tr>\n<td>vbExclamation<\/td>\n<td>Shows the warning message icon<\/td>\n<\/tr>\n<tr>\n<td>vbInformation<\/td>\n<td>Shows the information icon<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>MsgBox Icons &#8211; Critical<\/h3>\n<p>If you want to show a critical icon in your MsgBox, use the vbCritical constant. You can use this along with other button constants (by putting a + sign in between the codes).<\/p>\n<p>For example, below is a code that will show the default OK button with a critical icon.<\/p>\n<pre>Sub MsgBoxCriticalIcon()\nMsgBox \"This is a sample box\", vbCritical\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26435 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon.png\" alt=\"Excel VBA Msgbox - critical icon\" width=\"244\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon.png 244w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-50x43.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-117x100.png 117w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-235x200.png 235w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-176x150.png 176w\" sizes=\"(max-width: 244px) 100vw, 244px\" \/><\/p>\n<p>If you want to show the critical icon with Yes and No buttons, use the following code:<\/p>\n<pre>Sub MsgBoxCriticalIcon()\nMsgBox \"This is a sample box\", vbYesNo + vbCritical\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26436 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO.png\" alt=\"Excel VBA Msgbox - critical icon YesNO\" width=\"268\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO-50x39.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO-250x194.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO-129x100.png 129w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO-258x200.png 258w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-critical-icon-YesNO-193x150.png 193w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Icons &#8211; Question<\/h3>\n<p>If you want to show a critical icon in your MsgBox, use the vbQuestion constant.<\/p>\n<pre>Sub MsgBoxQuestionIcon()\nMsgBox \"This is a sample box\", vbYesNo + vbQuestion\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26437 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon.png\" alt=\"Excel VBA Msgbox - question icon\" width=\"268\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon-50x39.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon-250x194.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon-129x100.png 129w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon-258x200.png 258w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-question-icon-193x150.png 193w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Icons &#8211; Exclamation<\/h3>\n<p>If you want to show an exclamation icon in your MsgBox, use the vbExclamation constant.<\/p>\n<pre>Sub MsgBoxExclamationIcon()\nMsgBox \"This is a sample box\", vbYesNo + vbExclamation\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26438 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon.png\" alt=\"Excel VBA Msgbox - exclamation icon\" width=\"268\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon-50x39.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon-250x194.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon-129x100.png 129w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon-258x200.png 258w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-exclamation-icon-193x150.png 193w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h3>MsgBox Icons &#8211; Information<\/h3>\n<p>If you want to show an information icon in your MsgBox, use the vbInformation constant.<\/p>\n<pre>Sub MsgBoxInformationIcon()\nMsgBox \"This is a sample box\", vbYesNo + vbInformation\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26439 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information.png\" alt=\"Excel VBA Msgbox - information\" width=\"268\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information.png 268w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information-50x39.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information-250x194.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information-129x100.png 129w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information-258x200.png 258w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-information-193x150.png 193w\" sizes=\"(max-width: 268px) 100vw, 268px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Customizing-Title-and-Prompt-in-the-MsgBox\"><\/span>Customizing Title and Prompt in the MsgBox<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When using MsgBox, you can customize the title and the prompt messages.<\/p>\n<p>So far, the example we have seen have used Microsoft Excel as the title. In case you don&#8217;t specify the title argument, MsgBox automatically uses the title of the application (which has been Microsoft Excel in this case).<\/p>\n<p>You can customize the title by specifying it in the code as shown below:<\/p>\n<pre>Sub MsgBoxInformationIcon()\nMsgBox \"Do you want to continue?\", vbYesNo + vbQuestion, \"Step 1 of 3\"\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26446 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title.png\" alt=\"Excel VBA Msgbox - title\" width=\"282\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title.png 282w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title-50x37.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title-250x184.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title-136x100.png 136w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title-271x200.png 271w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-title-203x150.png 203w\" sizes=\"(max-width: 282px) 100vw, 282px\" \/><\/p>\n<p>Similarly, you can also customize the prompt message.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26448 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt.png\" alt=\"Excel VBA Msgbox - prompt\" width=\"282\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt.png 282w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt-50x37.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt-250x184.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt-136x100.png 136w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt-271x200.png 271w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-prompt-203x150.png 203w\" sizes=\"(max-width: 282px) 100vw, 282px\" \/><\/p>\n<p>You can also add line breaks in the prompt message.<\/p>\n<p>In the below code, I have added a line break using &#8216;vbNewLine&#8217;.<\/p>\n<pre>Sub MsgBoxInformationIcon()\nMsgBox \"Do you want to continue?\" &amp; vbNewLine &amp; \"Click Yes to Continue\", vbYesNo + vbQuestion, \"Step 1 of 3\"\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-26449 aligncenter\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline.png\" alt=\"Excel VBA Msgbox - vbnewline\" width=\"282\" height=\"208\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline.png 282w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline-50x37.png 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline-250x184.png 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline-136x100.png 136w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline-271x200.png 271w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-vbnewline-203x150.png 203w\" sizes=\"(max-width: 282px) 100vw, 282px\" \/><\/p>\n<p>You can also use the carriage return character &#8211; Chr(13) &#8211; or line feed &#8211; Chr(10) to <a href=\"https:\/\/trumpexcel.com\/start-a-new-line-in-excel-cell\/\">insert a new line<\/a> in the prompt message.<\/p>\n<p>Note that you can add a new line to the prompt message only and not the title.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Assigning-MsgBox-Value-to-a-Variable\"><\/span>Assigning MsgBox Value to a Variable<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>So far, we have seen the examples where we have created message boxes and customized the buttons, icons, title, and prompt.<\/p>\n<p>However, clicking a button has done nothing.<\/p>\n<p>With MsgBox function in Excel, you can decide what you want to do when a user clicks a specific button. And this is possible as every button has a value associated to it.<\/p>\n<p>So if I click on the Yes button, the MsgBox function returns a value (6 or the constant vbYes) which I can use in my code. Similarly, is the user selects the No button, it returns a different value ((7 or the constant vbNo)) that I can use in the code.<\/p>\n<p>Below is a table that shows the exact values and the constant returned\u00a0by the MsgBox function. You don&#8217;t need to memorize these, just be aware of it and you can use the constants which are easier to use.<\/p>\n<table style=\"height: 237px;\" width=\"431\">\n<tbody>\n<tr>\n<td width=\"127\"><strong>Button Clicked<\/strong><\/td>\n<td width=\"64\"><strong>Constant<\/strong><\/td>\n<td width=\"64\"><strong>Value<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Ok<\/td>\n<td>vbOk<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>Cancel<\/td>\n<td>vbCancel<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>Abort<\/td>\n<td>vbAbort<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>Retry<\/td>\n<td>vbRetry<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>Ignore<\/td>\n<td>vbIgnore<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>Yes<\/td>\n<td>vbYes<\/td>\n<td>6<\/td>\n<\/tr>\n<tr>\n<td>No<\/td>\n<td>vbNo<\/td>\n<td>7<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Now let&#8217;s see how we can control the VBA macro code based on what button a user clicks.<\/p>\n<p>In the below code, if the user clicks Yes, it displays the message &#8220;You Clicked Yes&#8221;, and if the user clicks No, it displays, &#8220;You clicked No&#8221;.<\/p>\n<pre>Sub MsgBoxInformationIcon()\nResult = MsgBox(\"Do you want to continue?\", vbYesNo + vbQuestion)\nIf Result = vbYes Then\nMsgBox \"You clicked Yes\"\nElse: MsgBox \"You clicked No\"\nEnd If\nEnd Sub<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-26452 size-full\" src=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt.gif\" alt=\"Yes No prompt based on user selection\" width=\"356\" height=\"260\" srcset=\"https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt.gif 356w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt-50x37.gif 50w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt-250x183.gif 250w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt-137x100.gif 137w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt-274x200.gif 274w, https:\/\/trumpexcel.com\/wp-content\/uploads\/2018\/07\/Excel-VBA-Msgbox-Yes-No-prompt-205x150.gif 205w\" sizes=\"(max-width: 356px) 100vw, 356px\" \/><\/p>\n<p>In the above code, I have assigned the value of the MsgBox function to the Result variable. When you click Yes button, the Result variable gets the vbYes constant (or the number 6) and when you click No, the Result variable gets the vbNo constant (or the number 7).<\/p>\n<p>Then I used an <a href=\"https:\/\/trumpexcel.com\/if-then-else-vba\/\" rel=\"noopener\">If Then Else<\/a> construct to check if the Result variable holds the value vbYes. If it does, it shows the prompt &#8220;You Clicked Yes&#8221;, else it shows &#8220;You clicked No&#8221;.<\/p>\n<p>You can use the same concept to run a code if a user clicks Yes and exit the sub when he\/she clicks No.<\/p>\n<div class=\"cbyellow\">Note: When you assign the MsgBox output to a variable, you need to put the arguments of MsgBox function in parenthesis. For example, in the line <strong><em>Result = MsgBox(&#8220;Do you want to continue?&#8221;, vbYesNo + vbQuestion)<\/em><\/strong>, you can see that the arguments are within parenthesis.<\/div>\n<p>If you want to further dig into the Message Box function, here is the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/vba\/language-reference-vba\/articles\/msgbox-function\" target=\"_blank\" rel=\"noopener noreferrer\">official document on it<\/a>.<\/p>\n<p><strong>You May Also Like the Following Excel VBA Tutorials:<\/strong><\/p>\n<ul>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-split-function\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel VBA Split Function<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-vba-instr\/\" target=\"_blank\" rel=\"noopener noreferrer\">Excel VBA InStr Function.<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-ranges\/\" rel=\"noopener\">Working with Cells and Ranges in Excel VBA<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-worksheets\/\" rel=\"noopener\">Working with Worksheets in VBA<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-workbook\/\" rel=\"noopener\">Working with Workbooks in VBA<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-loops\/\" rel=\"noopener\">Using Loops in Excel VBA<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-data-types-variables-constants\/\" target=\"_blank\" rel=\"noopener noreferrer\">Understanding Excel VBA Data Types (Variables and Constants)<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/personal-macro-workbook\/\" rel=\"noopener\">How to Create and Use Personal\u00a0Macro Workbook in Excel<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-macro-examples\/\" rel=\"noopener\">Useful Excel Macro Code Examples<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/for-next-loop-excel-vba\/\" rel=\"noopener\">Using For Next Loop in Excel VBA.<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/vba-events\/\" rel=\"noopener\">Excel VBA Events \u2013 An Easy (and Complete) Guide.<\/a><\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/run-a-macro-excel\/\" rel=\"noopener\">How to Run a Macro in Excel &#8211; A Complete Step-by-Step Guide<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/excel-add-in\/\" rel=\"noopener\">How to Create and Use an Excel Add-in<\/a>.<\/li>\n<li><a href=\"https:\/\/trumpexcel.com\/active-cell-vba-excel\/\" target=\"_blank\" rel=\"noopener\">Using Active Cell in VBA in Excel (Examples)<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>In Excel VBA, you can use the MsgBox function to display a message box (as shown below): A MsgBox is nothing but a dialog box that you can use to inform your users by showing a custom message or get some basic inputs (such as Yes\/No or OK\/Cancel). While the MsgBox dialog box is displayed, &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Excel VBA MsgBox [Message Box] &#8211; All You Need to Know!\" class=\"read-more button\" href=\"https:\/\/trumpexcel.com\/vba-msgbox\/#more-26412\" aria-label=\"Read more about Excel VBA MsgBox [Message Box] &#8211; All You Need to Know!\">Read more<\/a><\/p>\n","protected":false},"author":80,"featured_media":26415,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,154],"tags":[],"class_list":["post-26412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vba-tips","category-vba-functions"],"_links":{"self":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts\/26412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/comments?post=26412"}],"version-history":[{"count":1,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts\/26412\/revisions"}],"predecessor-version":[{"id":47223,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/posts\/26412\/revisions\/47223"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/media\/26415"}],"wp:attachment":[{"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/media?parent=26412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/categories?post=26412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trumpexcel.com\/wp-json\/wp\/v2\/tags?post=26412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}