VBA get user input

Dim is used to declare a new variable. The word following Dim is the variables name and can be called later on after the variable value is assigned. As Variant indicates the variable can be any data type, text or a number.


Dim myValue As Variant

Dim = Declare new variable

myValue = new variables name

As Variant = Data type can vary, text or number.

myValue = InputBox("Message boxes help text here")
Sub Get_User_Input()
Dim myValue As Variant

myValue = InputBox("User input")
Range("B1").Value = myValue

End Sub

VBA to prompt user to take confirm msgbox question.  Designate what buttons to display in the message box by changing the constant value for example vbYesNo will display Yes button and No button on the user input message box.

Response = MsgBox("Did the Halt Trading emails generate successfully?", vbYesNo, Confirm)

vbOKOnly   0Display OK button only.
vbOKCancel   1Display OK and Cancel buttons.
vbAbortRetryIgnore   2Display AbortRetry, and Ignore buttons.
vbYesNoCancel   3Display YesNo, and Cancel buttons.
vbYesNo   4Display Yes and No buttons.
vbRetryCancel   5Display Retry and Cancel buttons.
vbCritical16Display Critical Message icon.
vbQuestion32Display Warning Query icon.
vbExclamation48Display Warning Message icon.
vbInformation64Display Information Message icon.
vbDefaultButton1   0First button is default.
vbDefaultButton2 256Second button is default.
vbDefaultButton3 512Third button is default.
vbDefaultButton4 768Fourth button is default.
vbApplicationModal   0Application modal. The user must respond to the message box before continuing work in the current application.
vbSystemModal4096System modal. On Microsoft Win16 systems, all applications are suspended until the user responds to the message box. On Microsoft Win32 systems, this constant provides an application modal message box that always remains on top of any other programs that you have running
'Get user input


Response = MsgBox("Did the Halt Trading emails generate successfully?", vbYesNo, Confirm)
result = MsgBox("Enter Response",vbYesNoCancel)