ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA combo box (https://www.excelbanter.com/excel-programming/337552-vba-combo-box.html)

krhyme[_11_]

VBA combo box
 

hey all, easy question, cant find answer anywhere

How do I add items to a combo box in a VBA Form at design mode? Ther
is a LIST property but I can only add 1 item?

Thanks in advance

--
krhym
-----------------------------------------------------------------------
krhyme's Profile: http://www.excelforum.com/member.php...fo&userid=2522
View this thread: http://www.excelforum.com/showthread.php?threadid=39660


Dave Peterson

VBA combo box
 
Scroll down to the RowSource property.

Type in the range you want--if you're picking the list from a range.

If you're adding items one at at time, you could do it in the
UserForm_Initialize subroutine:

with me.combobox1
.additem "a"
.additem "b"
.additem "x"
end with

or even:
Dim myList As Variant
myList = Array("a", "b", "x")
Me.ComboBox1.List = myList



krhyme wrote:

hey all, easy question, cant find answer anywhere

How do I add items to a combo box in a VBA Form at design mode? There
is a LIST property but I can only add 1 item?

Thanks in advance!

--
krhyme
------------------------------------------------------------------------
krhyme's Profile: http://www.excelforum.com/member.php...o&userid=25225
View this thread: http://www.excelforum.com/showthread...hreadid=396601


--

Dave Peterson

krhyme[_12_]

VBA combo box
 

Perfect, Thanks Dave!


--
krhyme
------------------------------------------------------------------------
krhyme's Profile: http://www.excelforum.com/member.php...o&userid=25225
View this thread: http://www.excelforum.com/showthread...hreadid=396601


krhyme[_13_]

VBA combo box
 

It only shows the first item from my range, i tried ways:

1. Sheet1:A1:A5 in rowSource

2. insert--name-- define and listName in rowSource

My items are side by side instead of one of top of eachother, could
that be a problem?


--
krhyme
------------------------------------------------------------------------
krhyme's Profile: http://www.excelforum.com/member.php...o&userid=25225
View this thread: http://www.excelforum.com/showthread...hreadid=396601



All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com