Microsoft 365 Remonter une ligne en haut d'un tableau

MICHAEL

XLDnaute Occasionnel
Bonjour,
je souhaiterais remonter en ligne 2 la ligne dont la valeur colonne A correspond a G4
Merci de votre aide.
 

Pièces jointes

  • Nouveau Feuille de calcul Microsoft Excel.xlsx
    12.8 KB · Affichages: 9
Dernière édition:

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonsoir Michael,
Un essai en PJ avec :
VB:
Sub Remonte()
On Error GoTo Fin
IndexA = Application.Match([G4], [A:A], 0)
For i = 1 To 5
    Cells(2, i) = Cells(IndexA, i)
Next i
Rows(IndexA).EntireRow.Delete
Fin:
End Sub
 

Pièces jointes

  • Nouveau Feuille de calcul Microsoft Excel (2).xlsm
    16.2 KB · Affichages: 4

sylvanu

XLDnaute Barbatruc
Supporter XLD
Alors il faut passer en événementielle ( dans la feille Feuil1)
La macro est lancée quand on modifie une cellule de la feuille.
VB:
Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo Fin
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("G4")) Is Nothing Then
        IndexA = Application.Match(Target, [A:A], 0)
        For i = 1 To 5
        Cells(2, i) = Cells(IndexA, i)
        Next i
        Rows(IndexA).EntireRow.Delete
    End If
Fin:
End Sub
 

Pièces jointes

  • Nouveau Feuille de calcul Microsoft Excel (3).xlsm
    16.7 KB · Affichages: 7

Discussions similaires

Réponses
2
Affichages
173

Statistiques des forums

Discussions
314 022
Messages
2 104 718
Membres
109 111
dernier inscrit
Vico bac