Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default RemoveItem resetting Value in ComboBox

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default RemoveItem resetting Value in ComboBox

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default RemoveItem resetting Value in ComboBox

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
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
combobox list resetting? QB Excel Discussion (Misc queries) 2 January 20th 10 06:56 PM
Resetting Defaults jnix Setting up and Configuration of Excel 1 August 12th 09 10:29 PM
MSFlexGrid RemoveItem gti_jobert[_132_] Excel Programming 2 June 21st 06 11:30 AM
RemoveItem - ComboBox Mike Excel Programming 1 May 16th 06 04:51 PM
Resetting variables TBA[_2_] Excel Programming 3 December 18th 03 03:44 AM


All times are GMT +1. The time now is 09:03 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"