1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Private Sub Supprimer_Click()
On Error GoTo Gerreur
If ComboBox1 = "" Then
MsgBox "Saisissez un article !", vbExclamation
ComboBox1.SetFocus
Exit Sub
End If
If Valeur = ComboBox1.Text Then
Sheets(ComboBox1.Text).Activate
End If
MsgBox " Êtes-vous sûr de vouloir supprimer " & ComboBox1 & " ?", vbCritical + vbYesNoCancel + 256, "Attention"
If vbYes Then
Dim J As Long
Dim Plage As Range
Set Plage = Sheets("Liste articles").Range("B7", Range("B65536").End(xlUp))
For J = Plage.Cells.Count To 1 Step -1
If Plage.Cells(J).Value = ComboBox1 Then
Plage.Cells(J).EntireRow.Delete
End If
Application.DisplayAlerts = False
Sheets(ComboBox1.Text).Delete
Application.DisplayAlerts = True
Unload Me
If vbCancel Then
ComboBox1.SetFocus
ElseIf vbNo Then
Unload Me
End If
Exit Sub
Gerreur:
If Err.Number = 9 Then
Beep
MsgBox "" & ComboBox1.Text & " n'existe pas!"
ComboBox1.SetFocus
End If
Next
End If
End Sub |
Partager