Office tutorials

VBA InputBox window in Excel

InputBox window – entering data into VBA

It’s great, that you have already reached this part of VBA tutorial. After the VBA MsgBox window you will learn how to work with window for entering data into our VB code. Like the MsgBox window, this window has many additional parameters. Let’s try to create a simple program for entering data into cell A1 in your data sheet.

As you see, you can refer to the cell values ​​of your sheet by giving their name in quotes, using the Range command with cell address. In the brackets of the InputBox command, enter the message that will be displayed before the user enters the data. The A1 cell can also be addressed using the Cells command , as follows:


InputBox window – additional arguments

Below is the full list of the InputBox VBA function containing all arguments. The only mandatory argument that should be filled out is the Prompt argument. This is the message displayed before entering the value into the VBA code.

Prompt – is a mandatory argument. This is the text displayed in the InputBox window.

Title – optional argument. The title of the window, as in the case of the MsgBox window.

DefaultDefault value, displayed before we enter any data.

Left – Defines the position of the window in pixels from the left of your screen

Top – Defines the position of the window in pixels from the top of your screen

HelpFile – the argument is not mandatory. The argument specifies the reference to the help file. The file number of the help file is specified in the Context argument.

HelpContextId – argument is not mandatory. In the argument, you refer to the help file using the numerical value specified in the previous HelpFile.


Application examples – How to use the InputBox function window in Excel VBA?

Let’s imagine that you want to write a simple program that after entering the name in the VBA InputBox window will display a welcome message using the MsgBox window.

As you can see, combining phrases in VBA is done using the ” & ” character. Alternatively, we can also use the ” + ” sign here . Between the name and the greeting, you put the Enter character using the ” vbCrLf ” element .

Excel VBA course - VBA InputBox Example

Excel VBA course – VBA InputBox Example

Let’s write a short program in which we will use most of the window arguments we learned before. Below are the conditions:

  • Let’s create the Input window for entering the year of birth
  • The window from the default should indicate 1990
  • After entering the year of birth, the program should calculate the user’s age using the Date () and Year () functions
  • The window should be located in the upper left corner of the screen
  • At the end, the MsgBox window should be displayed with the user’s age and thanks


Excel VBA tutorial - Example of InputBox VBA

Excel VBA tutorial – Example of InputBox VBA

I attach the file with examples below:

Excercises (You can enter the solution in a comment)

1. Create a program using MsgBox and VBA InputBox, filling 4 cells of our sheet from A1 to A4 with data: Name, Surname, Growth and Age. When finished, a message indicating the completion of the data entry should be displayed.

2. Improve the last program. When the message about entering data appears, display all entered data using one MsgBox window. Try to place the window in the bottom right corner of the screen. Set also default values.


More examples of Excel VBA basics can be found in the Excel VBA Tutorial section and  Excel VBA Examples section. If you have any questions about this chapter, you can post them on the forum without logging in.

1 comment

    • keonh on June 24, 2018 at 7:31 am


    Excellent post. I was checking continuously this weblog and I am inspired!
    Extremely useful information particularly the ultimate part :
    ) I maintain such info a lot. I used to be seeking this particular information for a
    long time. Thanks and good luck.

Leave a Reply

Your email address will not be published.