Same Items in 3 different Combo Boxes

R

RyanH

I have three Combo Boxes in a UserForm that I need to display all 50 state
initials. I usually write my code like this:

Private Sub UserForm_Initialize()

With cboCustomerST
.AddItem "GA"
.AddItem "TN"
.AddItem "NY"
'list all other state
End With

End Sub

Is there a faster way to do this with 2 other combo boxes instead writing
code for each combo box?

Thanks in Advance,
Ryan
 
P

PaulW

for i = 1 to 3
userform1.controls("ComboBox" & i).additem "GA"
next i

Thats what I usually do.
 
J

Jim Cone

Another way...
Me.ComboBox2.List = Me.ComboBox1.List
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"RyanH" <
wrote in message
I have three Combo Boxes in a UserForm that I need to display all 50 state
initials. I usually write my code like this:

Private Sub UserForm_Initialize()
With cboCustomerST
.AddItem "GA"
.AddItem "TN"
.AddItem "NY"
'list all other state
End With
End Sub

Is there a faster way to do this with 2 other combo boxes instead writing
code for each combo box?
Thanks in Advance,
Ryan
 
R

Rick Rothstein \(MVP - VB\)

You could do it this way...

Dim S As Variant
For Each S In Split("AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA " & _
"KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ " & _
"NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT " & _
"VA WA WV WI WY")
ListBox1.AddItem S
ListBox2.AddItem S
ListBox3.AddItem S
Next

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top