Hello,
I'm trying to add a variable data from a ComboBox to fill the field setting in Autofilter Function, as said in the Topic title.
My current code only refers to A Column of the different sheets, but I'd like to add the ComboBox for the user to be able to change it.
Current Code with annotations :
Code
Private Sub Userform_Initialize()
ColonneFiltre1.Column() = Range("A1:C1").Value
'ColonneFiltre1 refers to ComboBox
End Sub
Private Sub BtnSésameOuvreToi_Click()
Dim K As Long
For K = 1 To Sheets.Count
Worksheets(K).Range("A1").AutoFilter Field:=1 'I want to change 1 by something like Field:=ColonneFiltre1.Column (I know this one wont work lol, as the ComboBox named ColonneFiltre1 refers to cell value, how can I refer the Column number of the selected one in this setting?)
Worksheets(K).Range("A1").AutoFilter Field:=1, Criteria1:=Array( _
N°Contrat1, N°Contrat2, N°Contrat3, N°Contrat4, N°Contrat5), Operator:=xlFilterValues
Next K
Unload SaisirFiltres
'Filter Column A from each sheet with data added in TextBox (N°Contrat1, N°Contrat2 etc...)
End Sub
Display More
Thank you in advance
Hemo