Msgbox si filtre Nok

Bonjour tous le monde,

J'utilise le code ci dessous pour filtrer un tableau. Dans ce cas précis je veux que ma macro filtre le nom "JF. LE JEUNE". Le problème que je rencontre et que si dans ce tableau il n'y a pas le message que je recherche Excel m'affiche un message d'erreur. Je souhaiterai remplacer ce message type par un message personnalisé.

Sub PA_JFLEJEUNE()

Sheets("Pland'actions").Select

Range("G10").Select

ActiveSheet.Range("$A$10:$AK$1000").AutoFilter Field:=7, Criteria1:= _

""

ActiveSheet.ShowAllData

ActiveSheet.Range("$A$10:$AK$1000").AutoFilter Field:=7, Criteria1:= _

"JF. LE JEUNE"

ActiveWorkbook.Worksheets("Pland'actions").AutoFilter.Sort.SortFields.Clear

ActiveWorkbook.Worksheets("Pland'actions").AutoFilter.Sort.SortFields.Add Key _

:=Range("D10:D1001"), SortOn:=xlSortOnValues, Order:=xlAscending, _

DataOption:=xlSortNormal

With ActiveWorkbook.Worksheets("Pland'actions").AutoFilter.Sort

.Header = xlYes

.MatchCase = False

.Orientation = xlTopToBottom

.SortMethod = xlPinYin

.Apply

End With

End Sub

Merci pour votre aide.

Ps : j'ai recherché dans les anciens sujets du forum avant de poster le message, si je suis passé à coté de quelque chose j'en suis désolé.

Bonjour,

Merci de joindre un petit fichier à ta demande.

Pour quelle raison, les données ne sont-elles pas sous forme de tableau (structuré) ?

Cdlt.

Sinon, ta procédure pourrait commencer ainsi :

Sub PA_JFLEJEUNE()
Dim rng As Range

    With Worksheets("Pland'actions")
        .Range("G10").Select
        .Range("$A$10:$AK$1000").AutoFilter Field:=7, Criteria1:=""
        .ShowAllData
        .Range("$A$10:$AK$1000").AutoFilter _
                Field:=7, _
                Criteria1:="JF. LE JEUNE"
        With .AutoFilter.Range
            On Error Resume Next
            Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
                      .SpecialCells(xlCellTypeVisible)
            On Error GoTo 0
        End With
        If rng Is Nothing Then
            MsgBox "Il n'y a pas de données !...", 64, "Information"
            .Range("$A$10:$AK$1000").AutoFilter Field:=7
            Exit Sub
        End If
    End With

    ' suite procédure...

End Sub

Je ne peux pas mettre le fichier en public car il contient des données que je ne peux divulguer mais si cela ne te dérange pas je peux te l'envoyer en privé.

Les données sont structuré dans un tableau.

Re,

Je t'ai envoyé un MP avec mon courriel.

Cdlt.

Rechercher des sujets similaires à "msgbox filtre nok"