• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

ComboBox dynamic filter

Afarag

Member
Hello there,

please i need help to modify this code to autofilter form combobox dynamically, but sounds like there is a trick with my code

Code:
Private Sub Super_list_Change()
  Dim shtDailyExport As Worksheet
  Dim varMonth As Variant
  Dim varsuper As Variant
  Dim varTeamLeader As Variant
  Dim varUserName As Variant
  Set shtDailyExport = Sheets("Data ()")
  varMonth = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("Month").DataBodyRange
  varsuper = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("Super").DataBodyRange
  varTeamLeader = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("Leader").DataBodyRange
  varUserName = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("User Name").DataBodyRange
  For i = 1 To UBound(varMonth)
    If varMonth(i, 1) = Me.Month_list.Value And _
      varsuper(i, 1) = Me.Super_list.Value And _
      varTeamLeader(i, 1) = Me.Leader_list.Value And _
      InStr(deb & "|", "|" & varUserName(i, 1) & "|") = 0 Then deb = deb & "|" & varUserName(i, 1)
  Next i
  Me.User_list.List = Split(Mid(deb, 2), "|")
  Set deb = Nothing
End Sub

this filter based on as per what select from Month the "Super" combobox will be filtered, then as per what "Super" filter, the "Leader" combobox will be filtered etc...

i face a problem with "Super" combobox

0
 
the function code of "Month" combobox

Code:
Private Sub Month_list_Change()
  Dim shtDailyExport As Worksheet
  Dim varMonth As Variant
  Dim varsuper As Variant
  Dim varTeamLeader As Variant
  Set shtDailyExport = Sheets("Data ()")
  varMonth = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("Month").DataBodyRange
  varsuperLeader = shtDailyExport.ListObjects("Table_SA_Database2").ListColumns("super").DataBodyRange
  For i = 1 To UBound(varMonth)
  On Error Resume Next
    If varMonth(i, 1) = Me.Month_list.Value And _
      InStr(deb & "|", "|" & varsuper(i, 1) & "|") = 0 Then deb = deb & "|" & varsuper(i, 1)
  Next i
  Me.Super_list.List = Split(Mid(deb, 2), "|")
  Set deb = Nothing
End Sub

perhaps might have the error

Gratefully,
 
Back
Top