Userform help

herpasymplex10

Board Regular
Joined
May 26, 2005
Messages
224
I've never used a Userform before so be easy on me...

I'm trying to create something my co-workers can use
I'd like to use a List Box on the form
which will give them a choice between 5 different
types of "return reasons"

I've got the listbox in the userform, but how do i add these different choices and make it so they can only choose one?

Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
There are various different methods to populate a listbox.

Do you have a list with these reasons somewhere?

If you don't you can use AddItem.
Code:
Private Sub UserForm_Initialize()
For I = 1 To 5
     Listbox1.AddItem "Reason " & I
Next I
End Sub
By default a listbox will only allow 1 choice.
 
Upvote 0
There are various different methods to populate a listbox.

Do you have a list with these reasons somewhere?

If you don't you can use AddItem.
Code:
Private Sub UserForm_Initialize()
For I = 1 To 5
     Listbox1.AddItem "Reason " & I
Next I
End Sub
By default a listbox will only allow 1 choice.

Thanks for the quick response:

1. nondefective special order merchandise: store error (store or consumer ordered incorrect material, customer cancelled etc.)

2. non-defective special order merchandise requiring repackaging 3. non-defective stock merchandise
4. Damaged merchandise

5. Defective merchandise
 
Upvote 0
Try this.
Code:
Private Sub UserForm_Initialize()
Dim arrListItems

arrListItems = Array("nondefective special order merchandise: store error (store or consumer ordered incorrect material, customer cancelled etc.", _
                     "non-defective special order merchandise requiring repackaging", _
                     "non-defective stock merchandise", _
                     "Damaged merchandise", _
                     "Defective merchandise")

ListBox1.List = arrListItems
End Sub
 
Upvote 0
Try this.
Code:
Private Sub UserForm_Initialize()
Dim arrListItems

arrListItems = Array("nondefective special order merchandise: store error (store or consumer ordered incorrect material, customer cancelled etc.", _
                     "non-defective special order merchandise requiring repackaging", _
                     "non-defective stock merchandise", _
                     "Damaged merchandise", _
                     "Defective merchandise")

ListBox1.List = arrListItems
End Sub


Thanks Norie.
I'm trying to add another Listbox to the userform but get an error:

Compile Error:
Ambiguous name detected: Userform_Initialize


(also. do you have any suggestions on a book on VBA? I'm a beginner and feel like i'm just copy and pasting what you are telling me but not understanding the basics)

Private Sub ListBox1_Click()

End Sub




Private Sub UserForm_Initialize()
Dim arrListItems

arrListItems = Array("nondefective special order merchandise: store error (store or consumer ordered incorrect material, customer cancelled etc.", _
"non-defective special order merchandise requiring repackaging", _
"non-defective stock merchandise", _
"Damaged merchandise", _
"Defective merchandise")

ListBox2.List = arrListItems
End Sub




Private Sub UserForm_Initialize()
Dim arrListItems

arrListItems = Array("Floor Tile", _
"Commercial Tile", _
"Robbins", _
"Bruce", _
"Hartco", _
"Samples/Literature", _
"Sheet", _
"Ceiling", _
"Ceiling Grid")

ListBox1.List = arrListItems
End Sub
 
Upvote 0
You can only have 1 initialize event.:)
 
Upvote 0
Hai...,

I am beginner to this VBA. May i know the reason why not use more initialize event.

Also how to add more combobox in userform.

Many Thanks in Advance..


Regards,

SellvakumarMech
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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