NewVeryNew
New Member
- Joined
- Jan 18, 2022
- Messages
- 15
- Office Version
- 2011
- Platform
- Windows
I am trying to filter out columns based on combo box drop down list but the second combo box show all the rows in the column and not just the ones the where filtered out.
Any clues?
Any clues?
VBA Code:
Option Explicit
Private Sub ComboBox1_Change()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Detailed")
Dim i As Integer
Dim n As Integer
n = Application.WorksheetFunction.Match(Me.ComboBox1.Value, sh.Range("3:3"), 0)
Me.ComboBox2.Clear
For i = 4 To Application.WorksheetFunction.CountA(sh.Cells(3, n).EntireColumn)
Me.ComboBox2.AddItem sh.Cells(i, n).Value
Next i
End Sub
Private Sub UserForm_Activate()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Detailed")
Dim i As Integer
Me.ComboBox1.Clear
For i = 1 To Application.WorksheetFunction.CountA(sh.Range("3:3"))
Me.ComboBox1.AddItem sh.Cells(3, i).Value
'ComboBox1.Text = "SubCat"
Next i
End Sub