Lesson#120: What is Input Box in VBA?

What is 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

First example showing only prompt

Sub new1()
InputBox (“Please enter a number between 11 to 99”)
End Sub
Example by showing the title on it
Sub new1()
ActiveCell = InputBox(“Please enter a number between 11 to 99”, “Enter a number”)
End Sub
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 X axis.
  • YPos − An optional parameter to set the position of 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 which identifies the help context number assigned by the author to the appropriate help topic.

Leave a Reply

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

Copyright 2017-2018@Excelabcd