Consulting

Results 1 to 3 of 3

Thread: Delete duplicates from VBA Combobox

  1. #1

    Delete duplicates from VBA Combobox

    Hi Everyone,

    I've got a list of ticket number in my excel and some of them are duplicates, which is not a problem.
    But I don't want to see these duplicates in my Combobox drop down list.

    Does anyone have a clue on this ? I've already written a code but it doesn't work.

    HTML Code:
    Private Sub UserForm_Initialize()
    
    Dim D As IntegerFor D = 5 To Range("I10").End(xlUp).Row
    Me.Cbx_ticket = Range("I" & D)If Me.Cbx_ticket.ListIndex = -1 Then Me.Cbx_ticket.AddItem Range("I" & D)
    Next D
    
    Me.Label_info.Caption = Sheets("Config").Range("e24")
    End Sub
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,027
    Use advancedfilter to create a duplicate-free list.

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,112
    try:
    Private Sub UserForm_Initialize()
    Me.Cbx_ticket.List = [unique(ticket)]
    Me.Label_info.Caption = Sheets("Config").Range("e24")
    End Sub
    and remove ticket from RowSource property:

    2021-01-13_230520.jpg
    (I hope you have UNIQUE available as a worksheet function)
    p45cal - - - - -This is my signature, it appears after all my posts. Below is not directed at anyone in particular - so don't take offence! - (You might guess why it's there though)
    If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •