Hello,

I'm new and very untalented in programming...

I have the following problem: I want to filter a database (BDDSheet) after multiple criteria, which in fact are multiple names listed in a column, in a different sheet (called CriteriaSheet). These names are the result of another macro, which copies them in the criteria sheet from another sheet (InterfaceSheet), once the user selects them there. So the criteria column varies in length every time this macro is activated. I tried the following code, but it does not work. I only works if I tell him the exact criteria range, for example "A1:17". But since this length always varies, I have no idea how to automize this...

Sub Macro()
'
Dim BDDSheet, InterfaceSheet, CriteriaSheet As Worksheet
Dim CriteriaSel As Range

With ThisWorkbook
Set BDDSheet = .Sheets("Base donnees brute")
Set InterfaceSheet = .Sheets("Interface")
Set CriteriaSheet = .Sheets("Criteria for advanced filter")
End With

Set CriteriaSel = CriteriaSheet.Range("A1").End(xlDown) ' If I replace with CriteriaSheet.Range("A1:A17") it works

BDDSheet.Select
Columns("A:AE").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=CriteriaSel, Unique:=False

End Sub

I really, really appreciate any help or ideas, Thank you very much in advance.

T.J.