My List box data does not show when I open the user form

karmaLee

New Member
Joined
Nov 23, 2021
Messages
24
Office Version
  1. 2016
Platform
  1. Windows
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
 
You said:
I used a clearing code to allow users to click a "Clear" command button to clear the user form

I suggest if you want to clear the userform. Try this:

VBA Code:
Private Sub CommandButton3_Click()
Unload Me
UserForm1.Show
End Sub
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You said:
I used a clearing code to allow users to click a "Clear" command button to clear the user form

I suggest if you want to clear the userform. Try this:

VBA Code:
Private Sub CommandButton3_Click()
Unload Me
UserForm1.Show
End Sub
Hello, thank you for your help! This code works perfectly to what I had in mind. Appreciate your help
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.

By the way just wondering why you need more then one userform.

And in reference to your question about Hide:
Code like this will Hide the Userform without unloading all the controls.
Unless you close the Workbook
Put this code some place in your Userform
Me.Hide
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.

By the way just wondering why you need more then one userform.

And in reference to your question about Hide:
Code like this will Hide the Userform without unloading all the controls.
Unless you close the Workbook
Put this code some place in your Userform
Me.Hide
This user form that I had trouble with is used to send data to a spreadsheet for data recording. The other user forms are used to link and update the inventory.
 
Upvote 0
This user form that I had trouble with is used to send data to a spreadsheet for data recording. The other user forms are used to link and update the inventory.
If your ever interested and do not already know there is a control in the Tool Box named "Multipage"

A workbook can have many sheets in one Workbook. And a Multipage on your userform can be the same and have many Multipage pages. Sort of like having 5 Userforms on the same Userform.
Each Multipage Page is just like another Worksheet.
Just incase your interested
 
Upvote 0
If your ever interested and do not already know there is a control in the Tool Box named "Multipage"

A workbook can have many sheets in one Workbook. And a Multipage on your userform can be the same and have many Multipage pages. Sort of like having 5 Userforms on the same Userform.
Each Multipage Page is just like another Worksheet.
Just incase your interested
Thanks for letting me know! I will consider using it
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top