XL 2021 Feuille filtrée, ne trier que les lignes visibles

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Bonjour à toutes et à tous,
Je vous souhaite un bon WE :)

La petite que samedi lol

Ma feuille est filtrée et je n'arrive pas à "placer .SpecialCells (xlCellTypeVisible)"
pour ne trier que les lignes visibles :mad:

Voici le code
VB:
    With ActiveSheet 'Appels 'CodeName
        If .FilterMode Then .ShowAllData 'si la feuille est filtrée
            With .Rows("7:" & .Range("a65536").End(xlUp).Row)
            If .Row < 7 Then Exit Sub 'sécurité
            .Sort .Columns(10), xlAscending, Header:=xlNo
            End With
    End With

Pourriez-vous me dire où placer le ".SpecialCells (xlCellTypeVisible)" ?
Si besoin, je ferai un p'tit fichier test.

Merci à toutes et à tous :)
Je continue mes tâtonnements...
:)
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Ce qu'il me reste à faire est de l'intégrer à ce code :
VB:
With ActiveSheet 'Appels 'CodeName
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
With .Rows("7:" & .Range("a65536").End(xlUp).Row)
If .Row < 7 Then Exit Sub 'sécurité
.Sort .Columns(10), xlAscending, Header:=xlNo
End With
End With
Ce que je ne sais pas faire pour l'instant :mad:
:)
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Mais peut-être que le code de mon fichier du #post2 est suffisant ?
VB:
Sub lignesVisibles()
Feuil2.Range("A3:zz" & Range("a65536").End(xlUp).Row).SpecialCells(xlVisible).Select: Selection.Copy
'Selection.SpecialCells(xlCellTypeVisible).Select
End Sub
En enlevant le "Selection.Copy" et à complèter pour trier...
Je testerai dès que je peux :)
 

Usine à gaz

XLDnaute Barbatruc
Supporter XLD
Mais je ne suis pas "personne" lol 🤪
Et voilà, c'est fait et ça fonctionne :
VB:
Sub lignesVisibles()
Feuil2.Range("A3:zz" & Range("a65536").End(xlUp).Row).SpecialCells(xlVisible).Select
With ActiveSheet 'Appels 'Code de Gérard
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
With .Rows("3:" & .Range("a65536").End(xlUp).Row)
If .Row < 3 Then Exit Sub 'sécurité
.Sort .Columns(2), xlAscending, Header:=xlNo
End With
End With
[a1].Select
End Sub
Fichier joint
:)
 

Pièces jointes

  • lignes visibles selection.xlsm
    338.7 KB · Affichages: 4

Discussions similaires

Réponses
2
Affichages
151
Réponses
11
Affichages
435

Statistiques des forums

Discussions
312 207
Messages
2 086 234
Membres
103 162
dernier inscrit
fcfg