Sub Worksheet_Change(ByVal Target As Range)
Me.Unprotect "jojo"
Application.EnableEvents = False 'désactive les évènements
If Not Application.Intersect(Target, Range("C6,C7,C9,H6:H7")) Is Nothing Then
Target.Value = UCase(Target.Value)
End If
On Error Resume Next
With Sheets(CStr([I3])).UsedRange
.Columns(3).name = "P" 'plage nommée
.Columns(4).name = "Q" 'plage nommée
[I4] = .Cells(Application.Match(1, [(P<>"")*(Q="")], 0), 3)
End With
If Err Then [I4] = "" 'RAZ
Application.EnableEvents = True 'réactive les évènements
Dim nom$, n&
With [C6]
If Intersect(Target, .Cells) Is Nothing Or .Value = "" Then Exit Sub
lig = 0 'RAZ de la variable Public
nom = Trim(.Value)
End With
With Sheets("BDD")
n = Application.CountIf(.[C:C], nom)
If n = 0 Then Exit Sub
If MsgBox("Il y a " & n & " ligne" & IIf(n = 1, "", "s") & " avec le nom '" & nom & "'." _
& vbLf & "Voulez-vous " & IIf(n = 1, "la", "les") & " consulter ?", 4, "Feuille '" & .name & "'") = 7 Then Exit Sub
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
.Range("A2:DA" & .Range("C" & .Rows.Count).End(xlUp).Row).AutoFilter 3, nom 'filtre automatique
.Activate
End With
Me.Protect "jojo"
End Sub