

#EXCEL VBA OPEN FOR INPUT AS CODE#
Please find the above code and ran it to check for output. MsgBox "Entered Text is: " & sName,, "Type2 Example" SName = Application.InputBox("Please Enter Text:", "Type2 Example",, ,, ,, 2) In this example when you enter text it will diplay entered text as a output using msgbox. Please find the following code and example. Using InputBox Function, you can accept a text string from the user. And finally you can see output in step6.Īccept a text string from the user using InputBox Now you can enter number in the input box. Once click on OK button it will highlight the entered text. It will display message like ‘Number is not valid’ in step3. You can enter any text in the input box to check the output. When we run the above code, it will ask user to enter the number. When we run above code, it will ask user to enter the number. MsgBox "My favourite Number is: " & iNum,, "Type1 Example" INum = Application.InputBox("Please Enter Your favourate Number:", "Example: Accept Number",, ,, ,, 1) And, It will highlight the user to reinter the number in specified place. Otherwise, it will display as ‘Number is not valid’ as a output. In this example when you enter number it will diplay entered number as a output using msgbox. Using InputBox Function, you can accept a Number from the user. Accept a Number from the User using InputBox Using InputBox Function, you can accept a Formula from the user. Accept an array of values from the User using InputBoxĪccept a formula from the User using InputBox.Accept an error value like #N/A from the User using InputBox.


Note: The following table lists the values that can be passed in the type argument.So that we can decide what an InpuBox is supposed to return based on type(8th Argument) Type Valueįor formula – If you want to accept a formula from the user you can use 0 as a typeįor number – If you want to accept a number from the user you can use 1 as a typeįor Text (a string) – If you want to accept a text string from the user you can use 2 as a typeįor logical value ( True or False) – If you want to accept a boolean value from the user you can use 4 as a typeįor cell reference – If you want to accept a range from the user you can use 8 as a typeįor an error value – If you want to accept an error value like #N/A from the user you can use 16 as a typeįor an array of values – If you want to accept an array of values from the user you can use 64 as a type Type – It specifies the return data type.Default returns text data type.(Optional)

HelpContextId – The context Id number of the Help topic in Help file.(Optional) HelpFile – The name of the Help file.(Optional) Left & Top – It Specifies a position of the dialog box.Default center of screen.(Optional) Title – The title for the InputBox.(Optional)ĭefault – It will specifies a value that will appear in the text box.(Optional) Prompt – The message to be displayed in the dialog box.
