Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 1st, 2005, 09:48 AM
abhaysanan abhaysanan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: NY
Posts: 3 abhaysanan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 35 sec
Reputation Power: 0
adding into combo box and removing duplicates

i have a list in my spreadsheet which needs to be added to my combo box list. The problem is that there are repeated number of these values. This is the code I have written but it does not work as i need it to. Not all the values have been added into the list. Also for every letter i type in the combo box this function is called making it slow. If some1 could correct it, it would be great. Thanks!

Private Sub ComboBox1_Change()
Dim i As Integer
Dim j As Integer
Dim count As Integer
Dim entry As String
Dim check As String

Range("C8",Range("C8").End(xlDown)).Select
count = Selection.Rows.count

Worksheets("Portfolio").Range("DR11")=count
For i = 8 To count
entry = Cells(i, 3).Value
ComboBox1.AddItem (entry)
Next i

For i = 8 To count
entry = Cells(i, 3).Value
For j = i + 1 To count
check = Cells(j, 3).Value
If entry = check Then
ComboBox1.RemoveItem (j)
End If
Next j
Next i
End Sub


It would be great too if some1 cud show me how to sort it.

Reply With Quote
  #2  
Old June 10th, 2005, 10:57 AM
snipered's Avatar
snipered snipered is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2005
Location: Birmingham, England
Posts: 909 snipered User rank is Sergeant (500 - 2000 Reputation Level)snipered User rank is Sergeant (500 - 2000 Reputation Level)snipered User rank is Sergeant (500 - 2000 Reputation Level)snipered User rank is Sergeant (500 - 2000 Reputation Level)snipered User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 20 h 48 m 50 sec
Reputation Power: 11
It's a bit awkward doing it that way. You could do it from a database easier.

However you decide, you need to do an sql statement.

Code:
sql = "select distinct field1, field2 from table 1"


You can set up your spreadsheet to act as a database but it's not recommended.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > adding into combo box and removing duplicates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT