Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding the same content to multiple combo boxes

Okay.. here's the deal, i have a user form in excel that
gathers information. In one section there is a series of
six combo boxes. What i have been trying to do is have
code in the UserForm_Initialize() sub that adds items to
the combo boxes. All six combo boxes need the same
information added to them.

what i would like to do is something like:
for each X in (1,2,3,4,5,6)
with Me.ComboBoxX
.AddItem "a"
.AddItem "b"
end with
next

trying to get it to go through all 6 boxes.. but this is
not working and i cant figure out how to get it to work
without reapeating the .AddItem list for each and every
box. is there a faster way to do it?

-keaven

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Adding the same content to multiple combo boxes

Keaven,

Load up combobox 1, and then set the List property of each of the
other comboboxes to the List property of combobox 1.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"keaven" wrote in message
...
Okay.. here's the deal, i have a user form in excel that
gathers information. In one section there is a series of
six combo boxes. What i have been trying to do is have
code in the UserForm_Initialize() sub that adds items to
the combo boxes. All six combo boxes need the same
information added to them.

what i would like to do is something like:
for each X in (1,2,3,4,5,6)
with Me.ComboBoxX
.AddItem "a"
.AddItem "b"
end with
next

trying to get it to go through all 6 boxes.. but this is
not working and i cant figure out how to get it to work
without reapeating the .AddItem list for each and every
box. is there a faster way to do it?

-keaven



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding the same content to multiple combo boxes

with Me.ComboBox1
.AddItem "a"
.AddItem "b"
end with

for i = 2 to 6
me.Controls("Combobox" & i).List = Combobox1.List
Next

--
Regards,
Tom Ogilvy

"keaven" wrote in message
...
Okay.. here's the deal, i have a user form in excel that
gathers information. In one section there is a series of
six combo boxes. What i have been trying to do is have
code in the UserForm_Initialize() sub that adds items to
the combo boxes. All six combo boxes need the same
information added to them.

what i would like to do is something like:
for each X in (1,2,3,4,5,6)
with Me.ComboBoxX
.AddItem "a"
.AddItem "b"
end with
next

trying to get it to go through all 6 boxes.. but this is
not working and i cant figure out how to get it to work
without reapeating the .AddItem list for each and every
box. is there a faster way to do it?

-keaven



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Adding the same content to multiple combo boxes

Chip, Tom.. thanks for your help, it worked great.
the second part was to have an item be removed from all
the other combo boxes once it was selected from another
one. this was complicated byt he fact that there was no
way to know in what order the comboboxes would be used.

This is how i ended up doing it... basically storing the
list index of the selection into a variable, then making
sure that the other comboboxes didnt have count of zero
(since i clear the combobox list after a choice is made),
then removing the corresponding list index. This is for
the first box, the other five are exactly the same, with
the exception of combobox referances of corse:

Private Sub StatBox1_Click()
' Lockes the stat choice in, and removes it
' from the other comboboxes
Dim strStat As String
Dim X As Integer
X = Me.StatBox1.ListIndex
'MsgBox X
strStat = Me.StatBox1.Value
Me.StatBox1.Clear
Me.StatBox1.Value = strStat
Me.StatBox1.Locked = True

Call FindStat(Me.StatBox1.Value, Me.stat1.Value)

If (Me.StatBox2.ListCount 0) Then
Me.StatBox2.RemoveItem (X)
End If
If (Me.StatBox3.ListCount 0) Then
Me.StatBox3.RemoveItem (X)
End If
If (Me.StatBox4.ListCount 0) Then
Me.StatBox4.RemoveItem (X)
End If
If (Me.StatBox5.ListCount 0) Then
Me.StatBox5.RemoveItem (X)
End If
If (Me.StatBox6.ListCount 0) Then
Me.StatBox6.RemoveItem (X)
End If
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
multiple combo boxes jeff Excel Discussion (Misc queries) 2 December 16th 08 05:02 PM
Multiple combo boxes with unique duplicates showing only Nemo New Users to Excel 0 July 6th 07 03:20 PM
Problem Adding new Combo Boxes [email protected] Excel Discussion (Misc queries) 2 September 12th 06 09:58 AM
multiple combo boxes LilyDog7 Excel Discussion (Misc queries) 4 October 17th 05 10:22 PM


All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"