Accepting Values and Popup Messages in Excel VBA

Home/Excel VBA/Accepting Values and Popup Messages in Excel VBA

Accepting Values and Popup Messages in Excel VBA – In this example we will see how to Accepting Values from user using InputBox and Show Popup Messages to user using MsgBox.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


We can show some Popup message to the user while executing the Macro using Message Box. Also, we can provide inputs to the macro when it is executing, it accept the values using Input Box. Generally we assign this value to a variable. In this section we will see how to use Input Box, Message Box and Variables.

Accepting Values and Popup Messages in Excel VBA: Message Box

To display a message to the user you can use the message box, we have already seen some examples on this in the previous topics. Here is the another sample code to display the message, copy this code and place in the module and run it.

Sub sbExampleMessaageBox()
MsgBox "Hello This is a Simple Message Box"
MsgBox "Hello This is a Simple Message Box with Title",, "Your Title Here"
MsgBox "Hello This is a Message Box with Yes and No Options", vbYesNo
MsgBox "Hello This is a Message Box with informationIcon", vbInformation
End Sub

There are different types of message boxes and their uses, we will see those details in the advanced topics.

Accepting Values and Popup Messages in Excel VBA: Input Box

Input Box is helpful to accept the values from the user, user can enter some values and those can be used in the our program.

Here is the simple Input Box Example, we will write a code to receive the user name and display that name in the message box. To display that particular name we have to store some where and then we can use it for displaying in the message box.

Here we have the need of variables, Variables can store some data while execution time and we can use then in our program.

Here, first we will accept the value from the user and we will store it in a variable, then we will display the value of that variable using Message Box, copy this code and place in the module and run it.

Sub sbExampleInputBox()
'Declaring a variable to store the inputbox value
'Dim statement creates a String variable called uName
Dim uName As String
'Accepting the value from the user and (right side statement)
'assigning that value into the variable uName ('=' is an assignment operator)
uName = InputBox("Please Enter Your Name")
'Displaying the value storeed in the variable using Message Box
MsgBox uName
End Sub

We will see the more options of the Input Box and more about Variables in the Advanced Topics.

By |March 10th, 2013|Excel VBA|2 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).


  1. joe November 9, 2013 at 10:28 PM - Reply

    Excellent website for Excel VBA!

    This page
    has two repeating words: “use” and “messages”

    Accepting Values and Popup Messages in Excel VBA – In this example we will see how to Accepting Values from use using InputBox and Popup Messages messages using MsgBox.

    • PNRao November 10, 2013 at 1:32 AM - Reply

      Thanks Joe, changed it!


Leave A Comment

Related pages

project timelines templatesexcel activesheethow to unprotect an excel workbookhow to make pivot table in excel 2007consolidate worksheets in excelprotect a worksheet in excelhow to activate activex controlpivot tables examplesmacro to delete blank rowshow do i do a pivot table in excel 2010excel hyperlink to cellvba vbyesnocancelexcel macro coding tutorialvba run commandvba loop through range by rowexcel graphs examplesconditional statements worksheetvba code to unprotect workbookhow to start macro in excelvba word rangehow to use averageif function in excel 2010vlookup formula example excel 2007vba cell colorhow do you unshare a workbookhow to write macro in excelvba string to integerexcel vba activate workbookexcel vba filter rangeprotect workbook in excel 2007excel dashboardingexcel isblank functionexcel save as xmlvba for loop rangevba message box syntaxexcel vba end xlupvba unprotect workbook without passwordhighlight column excelexcel vba tutorialhide a column in excelpastespecial xlpastevaluesvba create command buttonvlookup macrovba delete cell contentsdelete blanks in excelproject planning gantt chart excelvba xlshow to merge fields in exceldownloadable schedule templateexamples of spread sheetsexcel adjust cell heightexcel macro rowsabout macros in excelhow to learn excel macroshow to hide a row in excelhow to unprotect excel sheet 2010lookup excelmaking a dashboard in excellooping excelvba trim stringif elseif vbaexcel insert row shortcutexcel macro tutorial for beginnersusing hlookupwhile loops in vbahow to cut and paste on excelproject mobilization plan samplevba show userformwhat does merge cells mean in excelexcel vba case statementbuild a macro in excelvba programs for excelmicrosoft excel charts tutorialaverage vbacreate a userform in excelvba closehow to use sumif functionvlookup excel 2010 examplededuping in excelexcel flag duplicates