ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List of Different Cells (https://www.excelbanter.com/excel-programming/364325-list-different-cells.html)

ForSale[_74_]

List of Different Cells
 

In sheet1.range("b:b") I have a list of numbers. Some of the numbers
will repeat, some won't. In userform1.combobox1 I want to list all of
the different numbers (no repeats) from sheet1.range("b:b"). What is
the easiest way to do this?

Big Thanks.


--
ForSale
------------------------------------------------------------------------
ForSale's Profile: http://www.excelforum.com/member.php...o&userid=11896
View this thread: http://www.excelforum.com/showthread...hreadid=552094


jindon[_56_]

List of Different Cells
 

try

Code:
--------------------

Private Sub UserForm_Initialize()
Dim dic As Object, a, e
Set dic = CreateObject("scripting.dictionary")
dic.comparemode = vbTextCompare
With Sheets("Sheet1")
a = .Range("b1",.Range("b" & Rows.Count).End(xlUp)).Value
End With
For Each e In a
If Not IsEmpty(e) And Not dic.exists(e) Then dic.add e, Nothing
Next
If dic.count < 1 Then Exit Sub
Me.ListBox1.List = dic.keys
Set dic = Nothing
End Sub

--------------------


--
jindon
------------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...o&userid=13135
View this thread: http://www.excelforum.com/showthread...hreadid=552094


ForSale[_75_]

List of Different Cells
 

Fantastic! Now I just wish I could understand that.

Thanks.


--
ForSale
------------------------------------------------------------------------
ForSale's Profile: http://www.excelforum.com/member.php...o&userid=11896
View this thread: http://www.excelforum.com/showthread...hreadid=552094



All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com