I am following the exact steps on creating userform on this website http://www.excel-easy.com/vba/userform.html. I followed all the steps but I can't make it work.
Please see the image for the error.
When I pasted this code.
Private Sub UserForm_Initialize()
'Empty NameTextBox
NameTextBox.Value = ""
'Empty PhoneTextBox
PhoneTextBox.Value = ""
'Empty CityListBox
CityListBox.Clear
'Fill CityListBox
With CityListBox
.AddItem "San Francisco"
.AddItem "Oakland"
.AddItem "Richmond"
End With
'Empty DinnerComboBox
DinnerComboBox.Clear
'Fill DinnerComboBox
With DinnerComboBox
.AddItem "Italian"
.AddItem "Chinese"
.AddItem "Frites and Meat"
End With
'Uncheck DataCheckBoxes
DateCheckBox1.Value = False
DateCheckBox2.Value = False
DateCheckBox3.Value = False
'Set no car as default
CarOptionButton2.Value = True
'Empty MoneyTextBox
MoneyTextBox.Value = ""
'Set Focus on NameTextBox
NameTextBox.SetFocus
End Sub
this code will have error
Private Sub CommandButton1_Click()
DinnerPlannerUserForm.Show
End Sub
Please see the website first.
One of your controls is not named correctly. Adding
Option Explicit
to the top of your code modules will usually allow you to catch this type of error early.