How to add items to a combo box on user form

Shweta

Well-known Member
Joined
Jun 5, 2011
Messages
514
Hi All,

I want to add item in combo box placed on a user form

I am using the code:
combobox1.additem (" A")
combobox1.additem (" B")
combobox1.additem (" C")

This is adding the item to the combobox but not once

means when I click on the arrow of combobox, it shows

A
B
C
A
B
C
A
B
C

Instead of this, it should be

A
B
C


Please tell me if I am doing some mistake in coding.

Thanks
Shweta
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
It must be your Sub.

try this

Code:
Private Sub UserForm_Initialize()
ComboBox1.AddItem "A"
ComboBox1.AddItem "B"
ComboBox1.AddItem "C"
End Sub

imav :biggrin:
 
Upvote 0
Well then you need to Call it properly into your forms. What I posted works for me...

Code:
Private Sub UserForm_Initialize()
Call YourSub_Name
End Sub
 
Upvote 0
How about the following placed in the UserForm Code Window:

Code:
Private Sub UserForm_Initialize()
    With UserForm1.ComboBox1
        .AddItem ("A")
        .AddItem ("B")
        .AddItem ("C")
    End With
End Sub

If that doesn't work, can you post your Whole code.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,896
Members
452,948
Latest member
Dupuhini

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