Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think I'm missing something obvious, but:
I have a comboBox with the list populated with this code in UserForm_Initialize(): For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j This works fine and does not reset the value of the ComboBox1 when the UserForm1 loads. However, I have another UserForm2 that allows the user to enter Custom Values into the Lists for comboBox1. The code I use to repopulate the lists in ComboBox1 after the user inputs new values is this: If UserForm1.ComboBox1.ListCount 0 Then 'Removes current list For a = 11 To 0 Step -1 UserForm1.ComboBox1.RemoveItem a Next 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j Else 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j End If This works fine, except that it resets the value of the ComboBox1. I want the value to stay the same and just the list options to repopulate. Any ideas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
pseudo code to give you the concept.
v = Combobox1.Value ' populate the list combobox1.Value = v -- Regards, Tom Ogilvy "Drummer361" wrote: I think I'm missing something obvious, but: I have a comboBox with the list populated with this code in UserForm_Initialize(): For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j This works fine and does not reset the value of the ComboBox1 when the UserForm1 loads. However, I have another UserForm2 that allows the user to enter Custom Values into the Lists for comboBox1. The code I use to repopulate the lists in ComboBox1 after the user inputs new values is this: If UserForm1.ComboBox1.ListCount 0 Then 'Removes current list For a = 11 To 0 Step -1 UserForm1.ComboBox1.RemoveItem a Next 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j Else 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j End If This works fine, except that it resets the value of the ComboBox1. I want the value to stay the same and just the list options to repopulate. Any ideas? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes!!! Thanks Tom!
Tom Ogilvy wrote: pseudo code to give you the concept. v = Combobox1.Value ' populate the list combobox1.Value = v -- Regards, Tom Ogilvy "Drummer361" wrote: I think I'm missing something obvious, but: I have a comboBox with the list populated with this code in UserForm_Initialize(): For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j This works fine and does not reset the value of the ComboBox1 when the UserForm1 loads. However, I have another UserForm2 that allows the user to enter Custom Values into the Lists for comboBox1. The code I use to repopulate the lists in ComboBox1 after the user inputs new values is this: If UserForm1.ComboBox1.ListCount 0 Then 'Removes current list For a = 11 To 0 Step -1 UserForm1.ComboBox1.RemoveItem a Next 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j Else 'Rebuilds new list For j = 12 To 23 UserForm1.comboBox1.AddItem Worksheets("Sheet1").Cells(j, 11).Value Next j End If This works fine, except that it resets the value of the ComboBox1. I want the value to stay the same and just the list options to repopulate. Any ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
combobox list resetting? | Excel Discussion (Misc queries) | |||
Resetting Defaults | Setting up and Configuration of Excel | |||
MSFlexGrid RemoveItem | Excel Programming | |||
RemoveItem - ComboBox | Excel Programming | |||
Resetting variables | Excel Programming |