» Decide what an INPUTBOX is supposed to return using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - User Forms, Input boxes in VBA
VERSION - All Microsoft Excel Versions
This function displays a dialogbox that lets the user fill inn anything and returns the content as a string.
Sometimes you want to decide what the user is supposed to fill in,
instead of accepting any information. That's when you use the INPUTBOX-method :
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
The INPUTBOX-method has a third argument, Type, that decides what the user is allowd to insert in the INPUTBOX-dialog. Type can be one of the following :
Type :
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
Book Store:
Recommended Books:
- Special Edition Using Microsoft Excel 2002
- Microsoft Windows XP Step by Step (With CD-ROM)
- Financial Risk Manager Handbook, Second Edition
- Who Moved My Cheese? An Amazing Way to Deal with Change in Your Work and in Your Life
- The Sweet Potato Queens' Big-Ass Cookbook and Financial Planner
- The Intelligent Investor: The Classic Bestseller on Value Investing
No comments have been submitted.

