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
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.
- 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.
- 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.
- Now, you have to make sure that your macro name is selected and click the *Run * button.
- After running the macro, you will receive an input dialog box.
- 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
- Finally, the text have you inserted will insert only numbers as given below.
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!!
Further Reference:
- Excel VBA InputBox Function in Office 365 With Examples!!
- 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!!
- Formula to find Vlookup & Return Matching Values from Multiple worksheet
- Excel VBA Date And Time Function in Office 365 ~ Easy Tutorial!!








Oldest comments (0)