0
0
Excelspreadsheet~10 mins

UserForm basics in Excel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a UserForm named 'MyForm'.

Excel
Dim [1] As UserForm
Drag options to blanks, or click blank then click option'
AMyForm
BMainForm
CForm1
DUserForm1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name that is not the default UserForm name.
Trying to declare a UserForm with a name that doesn't exist.
2fill in blank
medium

Complete the code to show the UserForm named 'UserForm1'.

Excel
[1].Show
Drag options to blanks, or click blank then click option'
AUserForm
BForm1
CUserForm1
DMyForm
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong or misspelled UserForm name.
Forgetting to call the Show method.
3fill in blank
hard

Fix the error in the code to add a TextBox named 'txtName' to the UserForm.

Excel
UserForm1.Controls.Add "Forms.TextBox.1", "[1]"
Drag options to blanks, or click blank then click option'
Atxtname1
BtxtName
Ctxt_Name
Dtxtname
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect capitalization in the control name.
Adding a control with a name that doesn't follow naming conventions.
4fill in blank
hard

Fill both blanks to set the caption of a CommandButton named 'cmdSubmit' to 'Submit'.

Excel
UserForm1.[1].[2] = "Submit"
Drag options to blanks, or click blank then click option'
AcmdSubmit
BcmdSubmitButton
CCaption
DText
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Text' instead of 'Caption' property.
Using an incorrect control name.
5fill in blank
hard

Fill all three blanks to create a dictionary of TextBox names and their values from the UserForm.

Excel
Dim values As Object
Set values = CreateObject("Scripting.Dictionary")
For Each ctrl In UserForm1.Controls
  If TypeName(ctrl) = "[1]" Then
    values.Add ctrl.[2], ctrl.[3]
  End If
Next ctrl
Drag options to blanks, or click blank then click option'
ATextBox
BName
CText
DCommandButton
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CommandButton' instead of 'TextBox' in the type check.
Using 'Caption' instead of 'Text' to get the TextBox value.