Greetings and welcome to vbaexpress!
Originally Posted by
AeroAlx
Let's say I have in one column a list from one excel file. This list is quite long, and has duplicate entries. Now let's say I want a userform to pop up and give the user the ability to choose unique items from that list for the macro to do things with....
Just to get that first part - I think you mean that you only want the user to be able to select values that are only listed once in the 'list'.
If that is the case, here is but one way...
(I happen to grab a combobox, but .additem for listbox as welll...
Option Explicit
Private Sub UserForm_Initialize()
Dim rCell As Range
Dim MyRange As Range
With Sheet1
Set MyRange = .Range("A2:A" & .Cells(Rows.Count, 1).End(xlUp).Row)
For Each rCell In MyRange
If Evaluate("=COUNTIF(" & MyRange.Address & "," & rCell.Address(False, False) & ")") = 1 Then
Me.ComboBox1.AddItem rCell.Value
End If
Next
End With
End Sub
Mark