Results 1 to 10 of 10

Code required to Auto Populate 3rd Combobox based on 02nd Combobox Selection

Threaded View

  1. #1
    Registered User
    Join Date
    04-16-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    57

    Code required to Auto Populate 3rd Combobox based on 02nd Combobox Selection

    Hello,

    I have 3 columns A,B,C and 3 combobox.

    Data from Column A gets populated on 1st combobox, column B in 2nd and column C in 3rd.

    Below is the code I came across that achieves this -

    Option Explicit
    
    Private Sub cbPrimary_Change()
    
        Dim Name As String, R(), Counter As Integer, I As Integer
        Name = cbPrimary.Value
       
        For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
            If Cells(Counter, 1).Value = Name Then
                I = I + 1
                ReDim Preserve R(I - 1)
                R(I - 1) = Cells(Counter, 2).Value
            End If
        Next Counter
       
        UFSelection.cmSecondary.List = R
       
    End Sub
    
    Private Sub UserForm_Initialize()
    
        Dim Counter As Integer, R
       
        With CreateObject("Scripting.Dictionary")
            For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
                .Item(Cells(Counter, 1).Value) = ""
            Next Counter
            R = .keys
        End With
       
        cbPrimary.List = R
       
    End Sub
    
    Private Sub cmSecondary_Change()
        Dim Name As String, R(), Counter As Integer, I As Integer
        Name = cmSecondary.Value
       
        For Counter = 1 To Cells(Rows.Count, 2).End(xlUp).Row
            If Cells(Counter, 2).Value = Name Then
                I = I + 1
                ReDim Preserve R(I - 1)
                R(I - 1) = Cells(Counter, 3).Value
            End If
        Next Counter
       
        UFSelection.ComboBox1.List = R
       
    End Sub
    I'm looking for a code that can auto populate 3rd combobox based on what is selected in the 2nd combobox.

    Have attached sample sheet
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform Have Text Boxes Auto Populate Based on Combobox Selection & overwrite existing da
    By Rajesh shishodia in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2015, 02:06 AM
  2. Populate Combobox based on Selection in another Combobox
    By DomSza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2015, 08:19 AM
  3. [SOLVED] How do I populate a specific range in one ComboBox based of selection of another ComboBox?
    By gmr4evr1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-04-2015, 04:32 PM
  4. [SOLVED] Userform Have Text Boxes Auto Populate Based on Combobox Selection
    By strother1990 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2015, 04:30 PM
  5. Replies: 4
    Last Post: 03-02-2014, 03:33 AM
  6. Userform Combobox to populate based on selection in another combobox
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2014, 03:34 PM
  7. Auto populate Textboxes fro Combobox selection
    By Cuba64 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-03-2014, 05:52 PM

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