I created a user form and inserted a list box. When I open my user form, the data in the list box does not appear unless I click the "Cancel" button. I am unsure where I went wrong because I followed the instructions on Excel Easy
Here is my code:
Private Sub UserForm1_Initialize()
'code to empty textboxes, fill listboxes, uncheck checkboxes
'empty Date textbox1
TextBox1.Value = ""
'empty Code textbox2
TextBox2.Value = ""
'empty serial no. textbox3
TextBox3.Value = ""
'empty issues listbox1
ListBox1.Clear
'empty repair listbox2
ListBox2.Clear
'fill problems/issues listbox1
With ListBox1
.AddItem "Calibrate"
.AddItem "Unable to Alternate"
.AddItem "Broken solenoid head"
.AddItem "Faulty Motor"
.AddItem "Low Pressure"
.AddItem "Damaged Casing"
.AddItem "Buttons unable to be pressed"
.AddItem "Damaged Screw tracts"
.AddItem "Loose air outlet"
.AddItem "Loose ON/OFF panel"
.AddItem "Damaged back panel"
.AddItem "Damaged ON/OFF mains'"
.AddItem "Loose ON/OFF mains"
.AddItem "Conduct PM"
.AddItem "No Issue"
.AddItem "Others"
End With
'fill repair listbox2
With ListBox2
.AddItem "Calibrate"
.AddItem "Reconnect pressure tube"
.AddItem "Replace solenoid"
.AddItem "Replace solenoid head"
.AddItem "Replace motor"
.AddItem "Relace casing"
.AddItem "Readjust Buttons"
.AddItem "Hot Glue screw tracts"
.AddItem "Replace front panel"
.AddItem "Replace back panel"
.AddItem "Tightened air outlet"
.AddItem "Secure ON/OFF with hot glue"
.AddItem "Replace back casing"
.AddItem "Replace ON/OFF mains"
.AddItem "Conduct PM and ESA test"
.AddItem "No Issue"
.AddItem "Others"
End With
'empty remarks textbox5
TextBox5.Value = ""
'uncheck engineer checkboxes
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
CheckBox5.Value = False
CheckBox6.Value = False
CheckBox7.Value = False
End Sub
Private Sub CommandButton1_Click()
'code to transfer userform data inputs to service_records excel sheet
End Sub
Private Sub CommandButton2_Click()
'code to clear userform
Call UserForm1_Initialize
End Sub
Private Sub CommandButton3_Click()
'code to cancel userform
Unload Me
End Sub
Here is my code:
Private Sub UserForm1_Initialize()
'code to empty textboxes, fill listboxes, uncheck checkboxes
'empty Date textbox1
TextBox1.Value = ""
'empty Code textbox2
TextBox2.Value = ""
'empty serial no. textbox3
TextBox3.Value = ""
'empty issues listbox1
ListBox1.Clear
'empty repair listbox2
ListBox2.Clear
'fill problems/issues listbox1
With ListBox1
.AddItem "Calibrate"
.AddItem "Unable to Alternate"
.AddItem "Broken solenoid head"
.AddItem "Faulty Motor"
.AddItem "Low Pressure"
.AddItem "Damaged Casing"
.AddItem "Buttons unable to be pressed"
.AddItem "Damaged Screw tracts"
.AddItem "Loose air outlet"
.AddItem "Loose ON/OFF panel"
.AddItem "Damaged back panel"
.AddItem "Damaged ON/OFF mains'"
.AddItem "Loose ON/OFF mains"
.AddItem "Conduct PM"
.AddItem "No Issue"
.AddItem "Others"
End With
'fill repair listbox2
With ListBox2
.AddItem "Calibrate"
.AddItem "Reconnect pressure tube"
.AddItem "Replace solenoid"
.AddItem "Replace solenoid head"
.AddItem "Replace motor"
.AddItem "Relace casing"
.AddItem "Readjust Buttons"
.AddItem "Hot Glue screw tracts"
.AddItem "Replace front panel"
.AddItem "Replace back panel"
.AddItem "Tightened air outlet"
.AddItem "Secure ON/OFF with hot glue"
.AddItem "Replace back casing"
.AddItem "Replace ON/OFF mains"
.AddItem "Conduct PM and ESA test"
.AddItem "No Issue"
.AddItem "Others"
End With
'empty remarks textbox5
TextBox5.Value = ""
'uncheck engineer checkboxes
CheckBox1.Value = False
CheckBox3.Value = False
CheckBox4.Value = False
CheckBox5.Value = False
CheckBox6.Value = False
CheckBox7.Value = False
End Sub
Private Sub CommandButton1_Click()
'code to transfer userform data inputs to service_records excel sheet
End Sub
Private Sub CommandButton2_Click()
'code to clear userform
Call UserForm1_Initialize
End Sub
Private Sub CommandButton3_Click()
'code to cancel userform
Unload Me
End Sub