Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default combolist array.

IS there a way to create a combolist (vb) which adds everyone in column c and
only adds one instance of the name.

say

name1
name2
name3
name1
name1
name2
name4
name5

which turns into
name1
name2
name3
name4
name5
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default combolist array.

You didn't say if the ComboBox was on a UserForm or Worksheet, but the
coding would be similar. The following is for a UserForm.

Private Sub UserForm_Activate()
Dim iEnd As Long
Dim iRow As Long
Dim NoDupes As Collection
Dim ws As Worksheet

On Error Resume Next
Set ws = Worksheets("Sheet1")
iEnd = ws.Cells(65536, "C").End(xlUp).Row
Set NoDupes = New Collection
For iRow = 1 To iEnd
NoDupes.Add ws.Cells(iRow, "C"), ws.Cells(iRow, "C")
If Err.Number = 0 Then
ComboBox1.AddItem ws.Cells(iRow, "C")
Else
Err.Clear
End If
Next iRow
End Sub

Hth,
Merjet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default combolist array.

Dim iLastRow As Long
Dim aryData
Dim i As Long
Dim iItem As Long

With Worksheets("Sheet1")
iLastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
ReDim aryData(1 To iLastRow)
For i = 1 To iLastRow
If IsError(Application.Match(.Cells(i, "C").Value, aryData, 0))
Then
iItem = iItem + 1
aryData(iItem) = .Cells(i, "C").Value
End If
Next i
ReDim Preserve aryData(1 To iItem)
Me.ComboBox1.List = aryData
End With


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Sjakkie" wrote in message
...
IS there a way to create a combolist (vb) which adds everyone in column c
and
only adds one instance of the name.

say

name1
name2
name3
name1
name1
name2
name4
name5

which turns into
name1
name2
name3
name4
name5



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
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
How do I initialize a ComboList Box control from a range in an ex. ken Excel Programming 1 December 15th 04 04:25 PM
Available printers in a dropdown-combolist? NorTor Excel Programming 2 September 7th 03 05:21 PM


All times are GMT +1. The time now is 04:27 PM.

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"