Excel VBA InputBox Function in Office 365 With Examples!!
Tags: inputboxfunction, vbamacros
Published: 2020-12-17 12:07:43

---
title: Excel VBA InputBox Function in Office 365 With Examples!!
published: true
date: 2020-12-17 12:06:58 UTC
tags: InputBoxfunction,VBAMacros,VBAMacros
canonical_url: https://geekexcel.com/excel-vba-inputbox-function-office-365/
---

In Excel, the **[VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/) InputBox Function** helps to display a prompt in a dialog box for the user’s input text, and returns the information in the dialog box. In this tutorial, we are going to look at how to use the **VBA InputBox Function in Excel Office 365**.
## VBA InputBox-Syntax:

**InputBox(prompt [,title] [,default] [,xpos] [,ypos] [,helpfile] [,context])**

### Argument Explanations:

- **Prompt** – It is the string displayed as a message in the dialog box. The **maximum length** of the prompt is approximately **1024 characters**.
- **Title** – It is a string displayed in the title bar of the dialog box. It is an optional one.
- **Default** – This is an optional parameter used to display the string in a text box as the default response.
- **Xpos** – It is the position of the X-axis that represents the prompt distance from the left side of the screen horizontally. If xpos is omitted blank, the input box is horizontally centered.
- **Ypos** – An optional parameter. It is the position of the Y-axis that represents the prompt distance from the left side of the screen vertically. If ypos is omitted, the input box is vertically centered.
- **Helpfile** – An optional one. It is a string expression that identifies the Help file. It is also used to provide context-sensitive Help for the dialog box.
- **Context** – It is an optional parameter. A Numeric expression that identifies the Help context number assigned to the Help author to the appropriate Help topic.

## Prompt the users to Get Mobile Number:

Now we are going to see how to use the VBA InputBox Function in Excel.

- First, you need to open the [Visual Basic Editor](https://geekexcel.com/shortcut-to-open-vba-editor-in-microsoft-excel-365/) by clicking the[**ALT**  +  **F11**](https://geekexcel.com/shortcut-to-open-vba-editor-in-microsoft-excel-365/) Keys.
- Then, you need to go to the **insert tab** and **select** the **module** option from the menu.

![select module option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/EXCEL_eadfxDWr3B.png)<figcaption id="caption-attachment-19857">select module option</figcaption>

- After that, enter the below VBA codes in the code window.

VBA code for Add date in footer using Macros in Excel

Sub Getmobilenumber()  
Dim mobilenumber As String  
Do  
mobilenumber = VBA.InputBox(“Enter your Mobile Number(10 digits)”, “my system”)  
Loop Until VBA.Len(mobilenumber) = 10 And VBA.IsNumeric(mobilenumber)  
MsgBox “Your Mobile Number is:” & mobilenumber, vbInformation, ” information”  
End Sub  

- Save the code.

![Insert tab](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image-1.png)<figcaption id="caption-attachment-19844">Enter the code</figcaption>

- Then get back to the workbook and select the **Macros** option under the **Developer tab.**

![Macros option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image.png)<figcaption id="caption-attachment-19846">Macros option</figcaption>

- After that, it will display the **Macro**   **dialog box.**
- You need to select the **Macros name** and click the **Run** Button.

![Macros Box](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image2.png)<figcaption id="caption-attachment-19849">Macros Box</figcaption>

- It will display the input box as shown below.

![Input Box](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image3.png)<figcaption id="caption-attachment-19850">Input Box</figcaption>

- Here, you need to enter the 10 digits mobile number and click the **OK button**.

![Enter the input](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image4.png)<figcaption id="caption-attachment-19851">Enter the input</figcaption>

- It will display the result as shown in the below image.

![Result](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/12/image5.png)<figcaption id="caption-attachment-19852">Result</figcaption>

## Wrap-Up:

From the above article, we explained the **VBA InputBox Function in Excel** in a simple way. Please feel free to state your **query** or **feedback** for the above article. Thank you so much for reading!! To learn more, check out our website **[Geek Excel](https://geekexcel.com/)!! **