supersnoop
New Member
- Joined
- Aug 30, 2017
- Messages
- 4
My form has multiple text boxes and a combolist. Two buttons on the bottom, one for adding info into the spreadsheet, one for cancelling. When I click the cancel button, I get a 'Runtime error 91': Object variable or With block variable not set.
My code is below. What am I doing wrong?
Private Sub cancelBtn_Click()
Unload UserForm1
End Sub
Private Sub UserForm_Initialize()
For Each ctrl In Me.Controls
Select Case TypeName(ctrl)
Case "TextBox"
ctrl.Text = ""
Case "ComboBox"
ctrl.ListIndex = -1
End Select
Next
UserForm1.Show
End Sub
My code is below. What am I doing wrong?
Private Sub cancelBtn_Click()
Unload UserForm1
End Sub
Private Sub UserForm_Initialize()
For Each ctrl In Me.Controls
Select Case TypeName(ctrl)
Case "TextBox"
ctrl.Text = ""
Case "ComboBox"
ctrl.ListIndex = -1
End Select
Next
UserForm1.Show
End Sub