Bonjour,
pour simplifier j'ai mis les paramètres en Tableau nommé T_MotsCles
Comme ça tu peux le glisser ou le couper-coller où tu veux.
J'ai ajouté aussi l'acceptation du mot clé complet. Si tu saisis "d", excel pré-remplit et propose Défaut, que tu peux donc valider directement maintenant.
Le code adapté :
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Dim datas, pl As Range, c As Range, c2 As Range, i As Long, tmp
datas = [T_MotsCles].Value
For i = 1 To UBound(datas)
tmp = Split(Replace(datas(i, 2), "=", "!"), "!") ' ref Plage de cellules impactées
On Error GoTo suite
Set pl = Intersect(Target, Sheets(tmp(1)).Range(tmp(2)))
On Error GoTo -1
If Not pl Is Nothing Then
For Each c In pl ' pour chaque cellule modifiée
If Not c.HasFormula Then
If LCase(Target.Formula) = LCase(datas(i, 1)) Or LCase(Target.Formula) = LCase(datas(i, 3)) Then
Set c2 = [T_MotsCles].Cells(i, 3) ' cell des formats
Application.EnableEvents = False
Target = c2.Value ' nouvelle valeur
Application.EnableEvents = True
With c2
c.Interior.Color = IIf(.Interior.Color = 16777215, xlNone, .Interior.Color)
With .Font
c.Font.Name = .Name
c.Font.Size = .Size
c.Font.Color = .Color
c.Font.FontStyle = .FontStyle
End With
c.HorizontalAlignment = .HorizontalAlignment
c.VerticalAlignment = .VerticalAlignment
c.IndentLevel = .IndentLevel
End With
Exit For
End If
End If
Next c
End If
suite:
On Error GoTo -1
Next i
End Sub
Si tu pouvais éditer ton post de 19:41 pour supprimer le code stp.
Tu as commencé des modifs (erronées) et ça risque d'induire en erreur d'éventuels lecteurs.
eric