Filtrer et supprimer valeur en dehors d'une borne

Bonjour,

Je butte sur ce code simple mais qui ne donne pas le résultat escompté.

En effet si je filtre à la main en fonction des critères j'obtiens un nombre précis. Voir commentaire sur le fichier

https://www.cjoint.com/c/FGboyZmkJc1

Lorsque j'applique les codes ci-dessous, cela ne correspond pas à mon opération à la main.

maVariable = "USLAX"

'Deselect the subjects in variable
ActiveSheet.Range("A:A").AutoFilter Field:=1, criteria1:="<>" & maVariable, _
'Operator:=xlAnd

'Delete the filtered cells
ActiveSheet.Range("A1").CurrentRegion.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete

'Remove the filter from active sheet
ActiveSheet.AutoFilterMode = False
'Deselect the subjects in variable
ActiveSheet.Range("P:P").AutoFilter field:=16, criteria1:="<=360" _
        , Operator:=xlAnd, Criteria2:=">=10"
'
'Delete the filtered cells
ActiveSheet.Range("P1").CurrentRegion.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete

'Remove the filter from active sheet
ActiveSheet.AutoFilterMode = False

Si vous avez une idée ou un bout de code qui permet de faire un filtrer et supprimer les valeurs qui ne correspondent pas aux valeurs filtrées.

En vous remerciant par avance,

Cordialement & bon w-k

Bonjour

Un essai à tester. Te convient-il ?

Bye !

Hello GMB,

Merci de ton aide.

Cela marche nickel pour le filtre.

J'ai rajouté ce code pour supprimer les lignes filtrées et tout fonctionne.

Sub RemoveHiddenRows()
    Dim oRow As Range, rng As Range
    Dim myRows As Range
    With Sheets("Feuil1")
        Set myRows = Intersect(.Range("A:A").EntireRow, .UsedRange)
        If myRows Is Nothing Then Exit Sub
    End With

    For Each oRow In myRows.Columns(1).Cells
        If oRow.EntireRow.Hidden Then
            If rng Is Nothing Then
                Set rng = oRow
            Else
                Set rng = Union(rng, oRow)
            End If
        End If
    Next

    If Not rng Is Nothing Then rng.EntireRow.Delete
End Sub
Rechercher des sujets similaires à "filtrer supprimer valeur dehors borne"