Private Sub Worksheet_Change(ByVal Target As Range)
'code initial de jindon,francisé à ma sauce
'[oz+j18811|2250]
Dim rng As Range, r As Range, msg As String, x As Range, temp, check
Set rng = Intersect(Columns(1), Target)
If Not rng Is Nothing Then
Application.EnableEvents = False
For Each r In rng
If Not IsEmpty(r.Value) Then
If Application.CountIf(Columns(1), r.Value) > 1 Then
msg = msg & "Localisation: " & r.Address(0, 0) '& vbCrlf & r.Value
If x Is Nothing Then
r.Activate
Set x = r
Else
Set x = Union(x, r)
End If
End If
End If
Next
If Len(msg) Then
'Décommenter la ligne ci-dessous si on veut afficher le msgbox
'MsgBox msg, vbCritical, "Doublon détecté!"
x.Select
For Each r In x
r.Activate
Do
temp = Application.InputBox("Saisir la donnée correcte dans " & _
r.Address(0, 0), "Donnée incorrecte : " & IIf(Len(temp), temp, r.Value))
check = Application.CountIf(Columns(1), temp)
Loop Until (check = 0) * (temp <> "") * (temp <> False)
r.Value = temp
temp = ""
Next
End If
Set rng = Nothing
Set x = Nothing
Application.EnableEvents = True
End If
End Sub