LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default VBA question - autofilter combobox

another way would be to populate the combo in the form's initialise event
using a scripting runtime dictionary to filter out duplicates....
'''set a reference to MS Scripting runtime...

Private Sub UserForm_Initialize()
Dim dic As New Scripting.Dictionary
Dim rSource As Range, cell As Range
Dim sVal As String

' point to your column
Set rSource = Range("MyList")

With ComboBox1
For Each cell In rSource.Cells
sVal = cell.Value
If Not dic.Exists(sVal) Then
dic.Add sVal, sVal
.AddItem sVal
End If
Next
End With
Set dic = Nothing
End Sub

if the item is in the dictionary, we have it so skip on to the next item. If
an item isn't in the dictionary, then add it to the dictionary and to the
combobox. The dictionary object is extremely useful, Its effectively a
collection, but unlike a collection, with a dictianry you can test teh
existence of a key...you can also extract the keys and loop through them.
--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
I Feel Great!
---------------------------------
"ajliaks " wrote in message
...
Hi!

I have userform called "Exporting", which includes combobox called
"ChapExpCB"

Now ChapExpCB shows me a list of items included in a selected column.
Some of the items are repetead, and I need to Show each one just once.
Exacly like autofilter does.

How can I do?

Thanks.


---
Message posted from http://www.ExcelForum.com/



 
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 Question jlclyde Excel Discussion (Misc queries) 2 August 27th 09 09:31 PM
another combobox question teepee Excel Discussion (Misc queries) 2 May 13th 07 01:01 AM
ComboBox Question Duncan Edment Excel Worksheet Functions 1 August 1st 06 12:42 PM
ComboBox populated with data from AutoFilter Cristian Excel Programming 1 February 27th 04 12:32 PM
ComboBox Question Kevin Excel Programming 1 December 7th 03 04:54 PM


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