Dependent List Userform

animas

Active Member
Joined
Sep 28, 2009
Messages
396
I am creating a dependent list combo box in userform. I have 10,000 rows of data. While using the following code i am having error at red color line. "Runtime Error 13; Type Mismatch". How to resolve this? Or is there more efficient way?

Code:
Private Sub cmbDistrict_Change()
    Dim i As Integer
           
    cmbDistrict.Clear
    With Sheets("Data")
        LastRow = .Range("C" & Rows.Count).End(xlUp).Row
        For i = 2 To LastRow
            If .Cells(i, "C") = cbmBankName Then
                cmbDistrict.AddItem .Cells(i, "E")
            End If
        Next
    End With
   
End Sub



Private Sub UserForm_Activate()
    Dim LastRow As Long
    Dim LastVal, NextVal
    Dim i As Integer
    
    Application.ScreenUpdating = False
    
    
    With Sheets("Data")
        LastRow = .Range("C" & Rows.Count).End(xlUp).Row
        
        .Range("A1:Z" & LastRow).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes, _
                                        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
                                        DataOption1:=xlSortNormal
    
        For i = 2 To LastRow
            NextVal = .Cells(i, "C")
            If Not NextVal = LastVal Then
                [B][COLOR=Red]cmbBankName.AddItem NextVal[/COLOR][/B]
            End If
            LastVal = NextVal
        Next
    End With
    

    Me.cmbBankName.SetFocus
    
    Application.ScreenUpdating = True
    
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I am creating a dependent list combo box in userform. I have 10,000 rows of data.

Do you really think someone wants to have to wade through 10,000 items in a drop-down list???? :eek:
 
Upvote 0
i will be using 3 level of dependent lists. each list may contain upto 80 values in drop down. 10,000 records r within combination of 80x80x80.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top