Lesson#120: What is Input Box in VBA?

Lesson#120: What is Input Box in VBA?

What is an Input Box?

In VBA Input Box is a function that allows you to request information from the user who can type it in a text field of a dialog box.

The basic syntax of this function is:

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

The first example shows only prompt

Sub new1()
InputBox (“Please enter a number between 11 to 99”)
End Sub

For example by showing the title on it

Sub new1()
ActiveCell = InputBox(“Please enter a number between 11 to 99”, “Enter a number”)
End Sub

For example by showing a default value

Sub new1()
ActiveCell = InputBox(“Please enter a number between 11 to 99”, “Enter a number”, “Example: 68”)
End Sub
  • XPos − An optional parameter to set the position of the X axis.
  • YPos − An optional parameter to set the position of the Y axis.
  • helpfile − An optional parameter and a string expression that identifies the helpfile to provide context help for the dialogue box.
  • context − An optional parameter and a numeric expression that identifies the help context number assigned by the author to the appropriate help topic.
See also  Lesson#52: Let's check your lifeline with Excel

Hi! I am Puspendu. I am the founder and author of Excelabcd. I am little creative person, blogger and Excel-maniac guy. I hope you enjoy my blog.

Leave a Reply

Your email address will not be published. Required fields are marked *

*