Sub AnnulerTEL()
Dim tablo, Quoi, car$, i&, max&, plage As Range
If TextBox10 = "" Then
MsgBox "Aucun N° de téléphone saisi!", vbCritical
Exit Sub
End If
With ActiveSheet
'tableau des n° de tél de la plage utile
Set plage = Intersect(.Columns("X"), .UsedRange)
max = plage.Row + plage.Rows.Count - 1
Set plage = Intersect(.Columns("y"), .UsedRange)
j = plage.Row + plage.Rows.Count - 1
If j > max Then max = j
If max = 1 Then Exit Sub
tablo = .Range(.Cells(1, "x"), .Cells(max, "y"))
'transformation du n° de tél à trouver en nombre
For i = 1 To Len(TextBox10)
car = Mid(TextBox10, i, 1)
If car >= "0" And car <= "9" Then Quoi = Quoi & car
Next i
Quoi = Val(Quoi): j = 0
'boucle sur le tableau des n° de tél
If Quoi > 0 Then
Application.ScreenUpdating = False
For i = 2 To UBound(tablo)
If tablo(i, 1) = Quoi Or tablo(i, 2) = Quoi Then
j = j + 1: .Cells(i, 2) = CDate(Date)
.Cells(i, 2).Interior.ColorIndex = 15: .Cells(i, 2).Font.ColorIndex = 1
.Cells(i, 20) = "ANNULER": .Cells(i, 21) = "ANNULER"
.Range(.Cells(i, 20), .Cells(i, 22)).Interior.ColorIndex = 15
End If
Next i
Application.ScreenUpdating = True
End If
If j = 0 Then
MsgBox TextBox10 & " -> Téléphone introuvable.", vbExclamation
Else
MsgBox TextBox10 & " -> Téléphone trouvé dans " & j & " ligne(s).", vbExclamation
End If
TextBox10 = ""
End With
End Sub