Bonjour,
J'essai d'écrire une macro qui permet normalement de supprimer une ligne si la colonne AU égale 0.
Ça marche, mais si je sélectionne une ligne ou AU est vide alors il me supprime la ligne alors qu'il devrait pas.
je pensais que " <> 0 " permettait d'écarter les cellules différentes de 0 et même les cellules vides.
Merci d'avance pour votre tuyau
Public Sub Supprimer_ligne()
'
'Variables'
Dim rCel As Range, iRow%, iRowA%, iOK%
'
'ôter la protection de la feuille'
ActiveSheet.Unprotect Password:="*****"
Application.DisplayAlerts = False
On Error Resume Next
'
For x = 1 To 1
Do
iRow = 0
iOK = 0
Set rCel = Nothing
Set rCel = Application.InputBox( _
prompt:="Sélectionnez une cellule dans la ligne à supprimer", Type:=8)
If Not rCel Is Nothing Then
iRow = rCel.Row
If Range("AU" & iRow).Value <> 0 Then
MsgBox "Désolé mais cette ligne ne peut pas être supprimer." & Chr(10) & "Cette note de frais a déja été validé par votre responsable !" & Chr(10) & _
"Veuillez sélectionner une autre ligne dans une note de frais.", vbOKCancel, "Choix ligne"
iOK = 1
End If
End If
If iOK = 0 And iRow > 0 Then
If x = 1 Then iRowA = iRow
Rows(iRowA).Delete shift:=xlUp
End If
Loop Until iOK = 0 Or iRow = 0
If iRow = 0 Then
MsgBox "Procédure de suppression annulée par l'utilisateur !", vbInformation + vbOKOnly, "Copie - Info"
End If
Next
'Proteger la feuille de calcul'
ActiveSheet.Protect Password:="*****", DrawingObjects:=True, Contents:=True, Scenarios:=True
Application.DisplayAlerts = True
On Error GoTo 0
'
End Sub