Bonsoir à tous
Voila ci-dessous j'ai une macro de suppression, dans l’ensemble elle fonctionne très bien seulement je voudrai lui ajouter une condition qui se résume comme suit :
Si c'est la dernière ligne qu'on supprime qui est forcément (B12:F12) alors au lieu de .Delete ça sera .Clear
Voici la macro
Merci à vous tous par avance
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 Sub Supprimer_ligne() Dim c As Range Set c = ActiveCell If Not Intersect(c, Range("B12:F1048576")) Is Nothing And Selection.Column <> 1 And Selection.Column <> 7 Then If Selection.Rows.Count > 1 Then MsgBox "Vous ne pouvez pas supprimer plusieurs lignes à la fois !", vbCritical, "Suppression impossible" Exit Sub End If If Application.CountA(Cells(c.Row, "B").Resize(, 5)) > 0 Then If MsgBox("Voulez-vous vraiment supprimer l'opération attribuée à (" & ActiveCell & ") ?", vbYesNo, "Confirmation") = vbYes Then c.EntireRow.Delete End If Else MsgBox "Vous ne pouvez pas supprimer une ligne vide !", vbCritical, "Suppression impossible" End If Else MsgBox "Vous ne pouvez pas supprimer cette ligne car votre sélection est hors zone de suppression", vbCritical, "Suppression impossible" End If End Sub
Cordialement
Partager