0
0
Excelspreadsheet~20 mins

UserForm basics in Excel - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
UserForm Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📊 Formula Result
intermediate
2:00remaining
What is the output of this VBA code in a UserForm?
Consider a UserForm with a TextBox named TextBox1 and a CommandButton named CommandButton1. The following code runs when the button is clicked:

Private Sub CommandButton1_Click()
    MsgBox "Hello, " & TextBox1.Text
End Sub

What happens when the user types Anna in the TextBox and clicks the button?
Excel
Private Sub CommandButton1_Click()
    MsgBox "Hello, " & TextBox1.Text
End Sub
AA message box appears showing: Hello, Anna
BThe TextBox clears and no message appears
CAn error message appears because TextBox1.Text is invalid
DNothing happens when the button is clicked
Attempts:
2 left
💡 Hint
Think about how the TextBox's Text property is used in the message box.
Function Choice
intermediate
2:00remaining
Which VBA function correctly closes a UserForm?
You want to close a UserForm named MyForm when a button is clicked. Which VBA statement will close the form properly?
AExit UserForm
BClose MyForm
CUnload Me
DEnd MyForm
Attempts:
2 left
💡 Hint
Remember that Me refers to the current UserForm inside its code.
🎯 Scenario
advanced
3:00remaining
How to transfer UserForm input to a worksheet cell?
You have a UserForm with a TextBox named TextBoxName and a CommandButton. When the button is clicked, you want to put the text from the TextBox into cell A1 of Sheet1. Which code snippet inside the button click event will do this correctly?
ARange("A1").Text = TextBoxName.Text
BCells(1, 1).Value = TextBoxName.Text
CSheet1.Cells(1, 1) = TextBoxName.Value
DWorksheets("Sheet1").Range("A1").Value = TextBoxName.Text
Attempts:
2 left
💡 Hint
Use the full reference to the worksheet and the Text property of the TextBox.
data_analysis
advanced
3:00remaining
What error occurs with this UserForm code?
Inside a UserForm, you have this code:

Private Sub CommandButton1_Click()
    Dim num As Integer
    num = CInt(TextBoxNumber.Text)
    MsgBox 100 / num
End Sub

If the user leaves TextBoxNumber empty and clicks the button, what happens?
Excel
Private Sub CommandButton1_Click()
    Dim num As Integer
    num = CInt(TextBoxNumber.Text)
    MsgBox 100 / num
End Sub
AMessage box shows 100
BRuntime error: Invalid use of Null or empty string in CInt
CMessage box shows 0
DNo error, message box shows Infinity
Attempts:
2 left
💡 Hint
What happens if you convert an empty string to an integer?
🧠 Conceptual
expert
2:00remaining
How does the Me keyword behave inside a UserForm?
In VBA UserForm code, what does the keyword Me refer to?
AThe current UserForm instance where the code runs
BThe Excel workbook containing the UserForm
CThe active worksheet in Excel
DThe module where the code is written
Attempts:
2 left
💡 Hint
Think about object-oriented programming and how Me is used in class modules.