Private Sub Worksheet_Change(ByVal Target As Range)
Dim colonne1a As String
Dim cellule As Range
Dim dl1 As Long ' dernière ligne
Dim lig As Long
Dim i As Integer
Dim C As Range
[B]If Not FeuilExist("patients") Then MsgBox "La feuille Patients n'existe pas": Exit Sub[/B]
Sheets("patients").Unprotect ("estherzina")
If Target.Address <> "$B$10" Then Exit Sub
With Sheets("Patients")
colonne1a = ""
For i = 1 To Len(Target.Address(0, 0))
If Asc(Mid(Target.Address(0, 0), i, 1)) > 64 Then
colonne1a = colonne1a & Mid(Target.Address(0, 0), i, 1)
End If
Next i
dl1 = .Range(colonne1a & "65536").End(xlUp).Row
lig = chercheligne("Patients", Target.Value, colonne1a & "2", colonne1a & dl1)
If lig = 0 Then
Select Case MsgBox("Le patient : " & Target.Value _
& vbCrLf & "Doesn't exists :" & .Range(colonne1a & 1) _
& vbCrLf & "Do you want to add him ?" _
& vbCrLf & "" _
, vbYesNo Or vbInformation Or vbDefaultButton1, Application.Name)
Case vbYes
UserForm1.Show
Case vbNo
Exit Sub
End Select
' .Range(colonne1a & dl1 + 1) = Target.Value
End If
End With
End Sub