Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > combobox unique entrys


Reply
 
Thread Tools Display Modes
  #1  
Old 06-19-2003, 04:03 AM
Marcs's Avatar
Marcs Marcs is offline
Centurion
 
Join Date: Mar 2003
Location: Germany
Posts: 131
Default combobox unique entrys


Hi
ive a little problem with my combobox
i have a spreadsheet with a dynamic range
which i connected to my combobox
but in this range there are more entrys of the same
and i want them only appear once in my combobox

i.e. there are multiple entrys of "food" and i want "food" only one time in my combobox

i know there must be a thread refereing to this but i searched for at least an hour and dont find it at all
please help anyway
__________________
Ater Sanguis is watching you - and the Wisdom of the Dragon helps him!
Reply With Quote
  #2  
Old 06-19-2003, 04:16 AM
italkid's Avatar
italkid italkid is offline
Down...

Retired Moderator
* Expert *
 
Join Date: Dec 2002
Location: Belgium.
Posts: 6,731
Default

You could do it this way :
Code:
Private Sub CommandButton1_Click() Dim R As Range, UniqVal As Variant Dim UniqList As New Collection ComboBox1.Clear On Error Resume Next For Each R In Sheets("thesheet").Range("A1", Sheets("thesheet").Range("A1").End(xlDown)) UniqList.Add R.Value, CStr(R.Value) Next R For Each UniqVal In UniqList ComboBox1.AddItem UniqVal Next UniqVal End Sub
Hope this helps...
Reply With Quote
  #3  
Old 06-19-2003, 04:20 AM
Aio's Avatar
Aio Aio is offline
Junior Contributor
 
Join Date: May 2002
Location: Makati City, Philippines
Posts: 307
Default

Since there is no property that force the combo/list box to have unique entries, I guess it's imprerative that you maintain the uniqueness in the rowsource. If you can't avoid it, then the only option is to disconnect it from the rowsource and load per item, taking a check if each item has been loaded. I suggest to do this first using an array so it would be faster.
__________________
"^!|=AIO=|!^"
Reply With Quote
  #4  
Old 06-19-2003, 04:25 AM
Marcs's Avatar
Marcs Marcs is offline
Centurion
 
Join Date: Mar 2003
Location: Germany
Posts: 131
Default

thanx that was exactly what i was looking for
i only use it with Userform_activate
and dont use a seperate commandbutton
thanx again
__________________
Ater Sanguis is watching you - and the Wisdom of the Dragon helps him!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox Within A MSHFlexgrid verno_25_02 Database and Reporting 3 06-18-2003 08:08 AM
How to determine if an item entered in cell on a worksheet is found in combobox on a pliant Excel 0 06-05-2003 07:54 AM
Unique records in combobox or datacombo djcybex General 2 03-23-2001 12:43 AM
Combo makes RTB`s visible? golash General 2 11-27-2000 02:16 PM
Unique combobox entries??? Rhoarke General 3 10-18-2000 01:10 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->