How To Decide what an INPUTBOX is supposed to return using VBA in Excel?
Tags: todecidewhataninputb, vbamacros
Published: 2021-10-19 02:57:07

---
title: How To Decide what an INPUTBOX is supposed to return using VBA in Excel?
published: true
date: 2021-10-15 11:06:01 UTC
tags: ToDecideWhatAnINPUTB,VBAMacros
canonical_url: https://geekexcel.com/how-to-decide-what-an-inputbox-is-supposed-to-return-using-vba-in-excel/
---

In this article, we will guide you on how to  **decide what an INPUTBOX is supposed to return using VBA ** in Microsoft Excel. Let’s get them below!! Get an official version of MS Excel from the following link: **[https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)**

## Example

- Firstly, in the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to  **copy and paste the code**  given below.

```
Sub DecideUserInput()
Dim bText As String, bNumber As Integer
    ' here is the INPUTBOX-function :
    bText = InputBox("Insert in a text", "This accepts any input")
    ' here is the INPUTBOX-method :
    bNumber = Application.InputBox("Insert a number", "This accepts numbers only", 1)
    MsgBox "You have inserted :" & Chr(13) & _
        bText & Chr(13) & bNumber, , "Result from INPUT-boxes"
End Sub

```

- After that, you need to  **save the code**  by selecting it and then  **close the window**.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Save-the-Code-40-1024x307.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- You need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Run-the-Code-32.png)<figcaption>Run the Code</figcaption>

- After running the macro, you will **receive an input dialog box**.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Input-Dialog-box.png)<figcaption>Input dialog box</figcaption>

- You need to **enter the following input** in the input dialog box.

```
**Accepted input:**
0 A formula
1 A number
2 Text
4 A logical value (True or False)
8 A cell reference, e.g. a Range-object
16 An error value, e.g. #N/A
64 An array of values
```

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Insert-Text.png)<figcaption>Insert text</figcaption>

- Finally, the **text** have you inserted will **insert only numbers** as given below.

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Output-1-1.png)<figcaption>Output 1</figcaption>

![](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/10/Output-2-4.png)<figcaption>Output 2</figcaption>

## A Short Summary

Here, we have explained the step-by-step procedure on how to  **decide what an INPUTBOX is supposed to return using VBA**  in Microsoft Excel. Make use of this. Please share your worthwhile  **feedback**  in the below  **comment**  section. To learn more, check out our website **[Geek Excel](https://geekexcel.com/)!!**

**Further Reference:**

- **[Excel VBA InputBox Function in Office 365 With Examples!!](https://geekexcel.com/excel-vba-inputbox-function-office-365/)**
- **[How to find Vlookup and Return the Matching Values from Multiple Worksheets?](https://geekexcel.com/how-to-find-vlookup-and-return-the-matching-values-from-multiple-worksheets/)**
- **[Lookup a Value and Return a Different Cell From the Table in Excel!!](https://geekexcel.com/how-to-lookup-a-value-and-return-a-different-cell-from-the-table-in-excel/)**
- **[Formula to find Vlookup & Return Matching Values from Multiple worksheet](https://geekexcel.com/formula-to-find-vlookup-return-matching-values-from-multiple-worksheet/)**
- **[Excel VBA Date And Time Function in Office 365 ~ Easy Tutorial!!](https://geekexcel.com/excel-vba-date-and-time-function/)**