QP School
User forms in VBA - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: Excel VBA Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=48)
+--- Thread: User forms in VBA (/showthread.php?tid=5231)



User forms in VBA - Qomplainerz - 07-27-2023

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