07-27-2023, 07:15 AM
Description:
UserForms are custom forms you can create to interact with users.
1. Input Box
InputBox allows you to prompt the user for input.
Example:
Sub ExampleInputBox()
Dim userInput As String
userInput = InputBox("Please enter your name:")
MsgBox "Hello, " & userInput & "!"
End Sub
2. Buttons
You can add buttons to UserForms and assign code to run when the button is clicked.
Example:
Private Sub btnOK_Click()
MsgBox "You clicked the OK button!"
End Sub
3. Dropdowns
Dropdowns (ComboBoxes) allow users to choose from a list of options.
Example:
Private Sub cboFruit_Change()
MsgBox "You selected: " & cboFruit.Value
End Sub
UserForms are custom forms you can create to interact with users.
1. Input Box
InputBox allows you to prompt the user for input.
Example:
Sub ExampleInputBox()
Dim userInput As String
userInput = InputBox("Please enter your name:")
MsgBox "Hello, " & userInput & "!"
End Sub
2. Buttons
You can add buttons to UserForms and assign code to run when the button is clicked.
Example:
Private Sub btnOK_Click()
MsgBox "You clicked the OK button!"
End Sub
3. Dropdowns
Dropdowns (ComboBoxes) allow users to choose from a list of options.
Example:
Private Sub cboFruit_Change()
MsgBox "You selected: " & cboFruit.Value
End Sub