Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default unique text additem combobox

Good Day Group,

When using the below code to "fill" a ComboBox how to ensure that
only unique text will be added. The text that is in Range ("A1:A1000") is of
this type:
001
001
001
002
003
003
004
as a result I would like the combobox listtext to show
001
002
003
004 etc

Brgds

CG Rosén
----------------------------------------------------------------------------------------------
With Worksheets("Sheet").Range("A1:A1000")

Set k = .Find(nr, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)

If Not k Is Nothing Then
firstAddress = k.Address
Do

r = k.Row

Me.ComboBox1.AddItem Mid(Sheets("Sheet1").Cells(r, 1).Text, 1, 3)

Set k = .FindNext(k)
Loop While Not k Is Nothing And k.Address < firstAddress
End If

End With


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default unique text additem combobox

See John Walkenbach's site for one method:

http://www.j-walk.com/ss/excel/tips/tip47.htm

--
Regards,
Tom Ogilvy


"CG Rosén" wrote in message
...
Good Day Group,

When using the below code to "fill" a ComboBox how to ensure that
only unique text will be added. The text that is in Range ("A1:A1000") is

of
this type:
001
001
001
002
003
003
004
as a result I would like the combobox listtext to show
001
002
003
004 etc

Brgds

CG Rosén
--------------------------------------------------------------------------

--------------------
With Worksheets("Sheet").Range("A1:A1000")

Set k = .Find(nr, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns)

If Not k Is Nothing Then
firstAddress = k.Address
Do

r = k.Row

Me.ComboBox1.AddItem Mid(Sheets("Sheet1").Cells(r, 1).Text, 1, 3)

Set k = .FindNext(k)
Loop While Not k Is Nothing And k.Address < firstAddress
End If

End With




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
additem to combobox with an array jocke Excel Discussion (Misc queries) 2 September 29th 05 07:56 PM
combobox additem masterphilch Excel Programming 2 October 25th 04 11:04 PM
AddItem Method - Combobox value Todd Huttenstine Excel Programming 2 April 21st 04 05:13 PM
additem to a combobox from other excel worksheet gelu Excel Programming 1 March 1st 04 04:36 PM
Multiple Column ComboBox using Additem Jimmi Excel Programming 2 September 24th 03 02:40 AM


All times are GMT +1. The time now is 01:20 PM.

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"