ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   POPULATE combobox (https://www.excelbanter.com/excel-programming/427445-populate-combobox.html)

sunilpatel

POPULATE combobox
 
I am new with combobox stuff. I have created one but how do you populate
with an array$ using vba. where do you write code?
A small example would be appreciated. Can't find a simple via google.

Thank



Jacob Skaria

POPULATE combobox
 
Private Sub CommandButton1_Click()
arrTemp = Array(1, 2, 3, 4, 5)
For intTemp = 0 To UBound(arrTemp)
UserForm1.ComboBox1.AddItem arrTemp(intTemp)
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"sunilpatel" wrote:

I am new with combobox stuff. I have created one but how do you populate
with an array$ using vba. where do you write code?
A small example would be appreciated. Can't find a simple via google.

Thank




Dave Peterson

POPULATE combobox
 
If you already have an array and you're creating a userform, you can use that
userform's initialize procedure.

Option Explicit
Private Sub UserForm_Initialize()

dim myArr as variant
myArr = array("a","b","c") 'or however you determined the array

me.combobox1.list = myArr

End Sub

sunilpatel wrote:

I am new with combobox stuff. I have created one but how do you populate
with an array$ using vba. where do you write code?
A small example would be appreciated. Can't find a simple via google.

Thank


--

Dave Peterson


All times are GMT +1. The time now is 12:56 PM.

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