Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Why does the list get bigger ?

The below code populates a Combobox from the selected value in Textbox2.

But i found if i change the value in Texbox2, the List STILL has the other
values from the previous list adding them to the new list.

How can i make sure when/If a value in Textbox2 is modified ONLY those
vlaues are listed ?


Private Sub TextBox2_Change()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Why does the list get bigger ?

Worked it out ended up with

Private Sub TextBox2_Change()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
Combobox3.Clear ' <==== Added this line here
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub






"Corey" wrote in message
...
The below code populates a Combobox from the selected value in Textbox2.

But i found if i change the value in Texbox2, the List STILL has the other
values from the previous list adding them to the new list.

How can i make sure when/If a value in Textbox2 is modified ONLY those
vlaues are listed ?


Private Sub TextBox2_Change()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


Corey....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why does the list get bigger ?

Private Sub TextBox2_Change()
Application.ScreenUpdating = False
Combobox1.Clear '<== added
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


--
Regards,
Tom Ogilvy

"Corey" wrote in message
...
The below code populates a Combobox from the selected value in Textbox2.

But i found if i change the value in Texbox2, the List STILL has the other
values from the previous list adding them to the new list.

How can i make sure when/If a value in Textbox2 is modified ONLY those
vlaues are listed ?


Private Sub TextBox2_Change()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


Corey....



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Why does the list get bigger ?

Guess you are using Combobox3

Private Sub TextBox2_Change()
Application.ScreenUpdating = False
Combobox3.Clear '<== added
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub

After I posted, I saw you came up with something similar, although I don't
know why you would loop through that range and remove anything you had just
added. That is what you are doing with the clear inside the loop - but
maybe that is what you really want.

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
Private Sub TextBox2_Change()
Application.ScreenUpdating = False
Combobox1.Clear '<== added
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


--
Regards,
Tom Ogilvy

"Corey" wrote in message
...
The below code populates a Combobox from the selected value in Textbox2.

But i found if i change the value in Texbox2, the List STILL has the
other values from the previous list adding them to the new list.

How can i make sure when/If a value in Textbox2 is modified ONLY those
vlaues are listed ?


Private Sub TextBox2_Change()
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("names")
On Error Resume Next
For i = 3 To 21
If .Cells(i, Val(TextBox2.Value)).Value < "" Then
ComboBox3.AddItem .Cells(i, Val(TextBox2.Value))

End If
Next i
End With
Application.ScreenUpdating = True
End Sub


Corey....





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
if bigger than Arne Hegefors Excel Worksheet Functions 2 February 13th 07 04:33 PM
We want bigger spreadsheets Dan DeCoursey Excel Discussion (Misc queries) 8 October 16th 06 03:41 PM
Excel 2000 (9.0.6926 SP3) spreadsheet getting bigger & bigger .... Leath Excel Discussion (Misc queries) 2 March 14th 06 06:04 AM
How can I get fonts bigger on my dropdown list? BetMo Excel Worksheet Functions 1 August 23rd 05 12:07 AM
Workbook Bigger and Bigger Ye Yint Win Excel Programming 1 June 21st 05 01:38 PM


All times are GMT +1. The time now is 10:39 AM.

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

About Us

"It's about Microsoft Excel"