How to Fill List box on Excel User-Form with Unique Values from Worksheet

Good evening!

I am looking for VBA code to for Filling a Listbox on Excel User-Form with Unique Values from Worksheet.

I have string values in a column. Some of them are repeats. I just want unique values as the source for the combo box please.

Thank you Raghu

Top Contributor Asked on July 12, 2017 in VBA: User Forms.
Add Comment
2 Answer(s)


We can follo several methods to fill the unique values from the worksheet to ListBox.

Here is my preferred method to add unique values from worksheet to list box. This example macro will read the data from active worksheet from column A and Fill the unique strings into list box. You can use this code for both List box and Combo Box.

VBA to Fill List box on Excel User-Form with Unique Values from Worksheet

Private Sub UserForm_Initialize()
strCol = "A" 'Column number
lRow = 10 'Last Row with Data
For iCntr = 1 To lRow
nLookUp = Application.WorksheetFunction.CountIf(Range(strCol & "1:" & strCol & iCntr), Range(strCol & iCntr))
'Add Only First Occurance
If nLookUp = 1 Then ListBox1.AddItem Range(strCol & iCntr)
End Sub


Keymaster Answered 5 days ago.
Add Comment

Thanks PN…

Top Contributor Answered 3 days ago.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.