Be the first user to complete this post

  • 0
Add to List

Input Boxes in VBA Excel (InputBox)

Input Box in VBA Excel is a feature where user can provide input during the runtime of a program. The provided input may or may not be validated further in code.

  • Open a new Excel WorkBook and press “Alt+F11” to open the Visual Basic Editor
  • Copy Paste the following code
Sub FnSomeValues

    intInput = InputBox("Enter the Number")

    If (intInput Mod 2) = 0 Then
        MsgBox "Even Number"
    Else
        MsgBox "Odd Number"
    End If

End Sub
  • Run the Macro
Input Box in Excel Macro-1
Input Box in Excel Macro-1
  • Enter '12' in InputBox and hit 'OK'
Input Box in Excel Macro -2
Input Box in Excel Macro -2

Click here to read about 'Msgbox in Excel Macro'