Microsoft 365 Déplacer la ligne visible après le filtre

  • Initiateur de la discussion Initiateur de la discussion iliess
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

iliess

XLDnaute Occasionnel
Bonjour
SVP je souhaite déplacer la ligne visible après un filtre vers la fin du tableau Excel en vba
voici mon code
VB:
Sub Garder()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Worksheets("Rapp")
LastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
FirstOfRowFilter = Range("TblData").Resize(Range("TblData").Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Row
Range("A" & FirstOfRowFilter & ":J" & FirstOfRowFilter).Cut
Range("A" & LastRow + 1 & ":J" & LastRow + 1).Insert Shift:=xlDown
End Sub

après l'exécution du code voici le message d'erreur dans la dernière ligne du code

1701089949913.png

svp qu'elle est la solution de ce problème
merci
 

Pièces jointes

Bonjour @iliess
Edit Bonjour @ChTi160

Essaye ceci

VB:
Sub Garder()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Worksheets("Feuil1")
LastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
FirstOfRowFilter = Range("TblData").Resize(Range("TblData").Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Row
Range("A" & FirstOfRowFilter & ":F" & FirstOfRowFilter).Cut

Range("TblData").AutoFilter ' Suppression des filtres

Range("A" & LastRow + 1 & ":F" & LastRow + 1).Insert Shift:=xlDown
'Run "filtre"
End Sub

Cela supprime le filtre

Mais que veux tu faire ?
 
Bonjour @ChTi160
Bonjour @Phil69970

merci pour vos réponses

j'ai ajouter cette ligne dans le code et ca marche très bien
VB:
Range("A" & FirstOfRowFilter & ":F" & FirstOfRowFilter).Cut Destination:=Range("A" & LastRow + 1 & ":F" & LastRow + 1)
Rows(FirstOfRowFilter & ":" & FirstOfRowFilter).Delete Shift:=xlUp

voici le nouveau code

Code:
Sub Garder()
Dim ws As Worksheet
Dim LastRow As Long
Set ws = Worksheets("Feuil1")
LastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
FirstOfRowFilter = Range("TblData").Resize(Range("TblData").Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Row
Range("A" & FirstOfRowFilter & ":F" & FirstOfRowFilter).Cut Destination:=Range("A" & LastRow + 1 & ":F" & LastRow + 1)
Rows(FirstOfRowFilter & ":" & FirstOfRowFilter).Delete Shift:=xlUp
Range("TblData").AutoFilter
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
232
Réponses
5
Affichages
235
Réponses
10
Affichages
281
Réponses
3
Affichages
491
Réponses
3
Affichages
193
Retour