Results 1 to 9 of 9

Excel VBA: Multi-level dependant lists ComboBoxes. some problem in extracting unique lists

Threaded View

talha.ansari Excel VBA: Multi-level... 07-23-2021, 08:00 PM
jindon Re: Excel VBA: Multi-level... 07-23-2021, 10:11 PM
talha.ansari Re: Excel VBA: Multi-level... 07-25-2021, 11:30 PM
AlphaFrog Re: Excel VBA: Multi-level... 07-23-2021, 11:19 PM
jindon Re: Excel VBA: Multi-level... 07-25-2021, 11:50 PM
talha.ansari Re: Excel VBA: Multi-level... 07-26-2021, 12:57 PM
jindon Re: Excel VBA: Multi-level... 07-26-2021, 07:58 PM
talha.ansari Re: Excel VBA: Multi-level... 07-27-2021, 10:37 AM
AliGW Re: Excel VBA: Multi-level... 07-27-2021, 10:40 AM
  1. #1
    Registered User
    Join Date
    07-23-2021
    Location
    Pakistan
    MS-Off Ver
    2019
    Posts
    10

    Question Excel VBA: Multi-level dependant lists ComboBoxes. some problem in extracting unique lists

    i have a file containing the sample userform of 3 sample combo boxes every next combobox is dependant to the previous.

    there is a simple vba behind it, which i think should work correctly.

    Option Explicit
    
    Private Sub UserForm_Initialize()
    ' set worksheet
    Dim sh As Worksheet
    Set sh = Sheets("Clients")
    'declare variable
    Dim i As Long
    For i = 2 To Application.WorksheetFunction.CountA(sh.Cells(1, 1).EntireColumn)
    If Application.WorksheetFunction.CountIf(sh.Range("A2", "A" & i), sh.Cells(i, 1)) = 1 Then
    Me.ComboBox1.AddItem sh.Cells(i, 1)
    End If
    Next i
    End Sub
    
    Private Sub ComboBox1_Change()
    Me.ComboBox2.Clear
    
    ' set worksheet
    Dim sh As Worksheet
    Set sh = Sheets("Clients")
    'declare variable
    Dim i As Long
    For i = 2 To Application.WorksheetFunction.CountA(sh.Cells(1, 1).EntireColumn)
    If sh.Cells(i, 1) = Me.ComboBox1.Value And _
    Application.WorksheetFunction.CountIf(sh.Range("B2", "B" & i), sh.Cells(i, 2)) = 1 Then
    
    Me.ComboBox2.AddItem sh.Cells(i, 2)
    
    End If
    Next i
    
    
    End Sub
    
    Private Sub ComboBox2_Change()
    Me.ComboBox3.Clear
    
    ' set worksheet
    Dim sh As Worksheet
    Set sh = Sheets("Clients")
    'declare variable
    Dim i As Long
    For i = 2 To sh.Range("A10000").End(xlUp).Row
    If sh.Cells(i, 1) = Me.ComboBox1.Value And sh.Cells(i, 2) = Me.ComboBox2.Value And _
    Application.WorksheetFunction.CountIf(sh.Range("C2", "C" & i), sh.Cells(i, 3)) = 1 Then
    
    Me.ComboBox3.AddItem sh.Cells(i, 3)
    
    End If
    Next i
    
    End Sub
    it does work for starting items but not for further. the issue is in
    Application.WorksheetFunction.CountIf(sh.Range("B2", "B" & i), sh.Cells(i, 2)) = 1
    as well as in
    Application.WorksheetFunction.CountIf(sh.Range("C2", "C" & i), sh.Cells(i, 3)) = 1
    when it try to get unique items for combobox list.

    any solution please.

    Comment: The query is also posted by me in MrExcel forum.
    Attached Files Attached Files
    Last edited by talha.ansari; 07-24-2021 at 06:02 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 06-04-2020, 06:12 PM
  2. [SOLVED] creating unique items lists for comboboxes... need a better way
    By Arnold Layne in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-13-2019, 11:09 AM
  3. [SOLVED] Multi Level Dependent Drop Down Lists
    By mysticmoron109 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-03-2015, 03:35 PM
  4. [SOLVED] Drop Lists - Dependant and returning Unique values only
    By marsofearth in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-04-2015, 04:38 PM
  5. Multiple Dependant Dropdown lists - need to show unique values only please
    By parsonsamie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-27-2014, 07:04 PM
  6. Multi-level Data Validation with Lists
    By saschagraef in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 12-16-2010, 08:49 AM
  7. Multi-level dependent lists
    By aussiemate in forum Excel General
    Replies: 6
    Last Post: 02-25-2010, 04:02 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1