Results 1 to 3 of 3

Thread: [RESOLVED] COMBOBOX with not dupes...

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,942

    Resolved [RESOLVED] COMBOBOX with not dupes...

    I have this sheet in column A are many value.
    I want to fill/populate combobox1 present in a userform with the first 3 digit of value in column A, but without duplicates...

    example:
    AED
    AFN
    ALL
    AMD
    ...
    XAF
    XCD
    XOF
    XPF

  2. #2
    Addicted Member
    Join Date
    Jan 2009
    Posts
    233

    Re: COMBOBOX with not dupes...

    first 3 digit or first 3 letters?

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: COMBOBOX with not dupes...

    Code:
    Private Sub CommandButton1_Click()
        '~~> This will add values from A1 to A10 in the combobox
        '~~> Change it as per your requirement
        For i = 1 To 10
            '~~> Add first 3 letters/digits
            ComboBox1.AddItem Left(Range("A" & i).Value, 3)
        Next i
        '~~> This will remove the duplicates
        Call RemoveDuplicates
    End Sub
    Sub RemoveDuplicates()
        Dim a As Integer, b As Integer, c As Integer
        a = ComboBox1.ListCount - 1
        Do While a >= 0
            For b = a - 1 To 0 Step -1
                If ComboBox1.List(b) = ComboBox1.List(a) Then
                    ComboBox1.RemoveItem b
                    a = a - 1
                End If
            Next b
            a = a - 1
        Loop
    End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width