B
bakman
Guest
Bonjour,
J'ai adapté une procédure qui pour l'instant donne satisfaction. Elle doit cependant être collée dans chaque objet worksheet. J'aimerais que cette procédure soit disponible en tant que module ou au niveau du workbook. Pourriez-vous m'aider à la modifier en conséquence ?
Je suis également preneur de toute modification qui vous semblera pertinente pour l'améliorer.
Cordialement.
---
La procédure en question :
Private Sub Worksheet_Change(ByVal Target As Range)
coloration Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
coloration Target
End Sub
Sub coloration(cellule)
On Error GoTo Fin
For Each code In Application.Range("formats")
If code.Value = cellule.Value Then
cellule.Interior.ColorIndex = code.Offset(0, 1).Interior.ColorIndex
cellule.Interior.Pattern = code.Offset(0, 1).Interior.Pattern
cellule.Interior.PatternColor = code.Offset(0, 1).Interior.PatternColor
cellule.Font.Color = code.Offset(0, 1).Font.Color
cellule.Font.Size = code.Offset(0, 1).Font.Size
cellule.Font.Bold = code.Offset(0, 1).Font.Bold
Exit Sub
End If
Next
cellule.Interior.ColorIndex = Application.Range("Nontrouvé").Interior.ColorIndex
Fin:
End Sub
J'ai adapté une procédure qui pour l'instant donne satisfaction. Elle doit cependant être collée dans chaque objet worksheet. J'aimerais que cette procédure soit disponible en tant que module ou au niveau du workbook. Pourriez-vous m'aider à la modifier en conséquence ?
Je suis également preneur de toute modification qui vous semblera pertinente pour l'améliorer.
Cordialement.
---
La procédure en question :
Private Sub Worksheet_Change(ByVal Target As Range)
coloration Target
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
coloration Target
End Sub
Sub coloration(cellule)
On Error GoTo Fin
For Each code In Application.Range("formats")
If code.Value = cellule.Value Then
cellule.Interior.ColorIndex = code.Offset(0, 1).Interior.ColorIndex
cellule.Interior.Pattern = code.Offset(0, 1).Interior.Pattern
cellule.Interior.PatternColor = code.Offset(0, 1).Interior.PatternColor
cellule.Font.Color = code.Offset(0, 1).Font.Color
cellule.Font.Size = code.Offset(0, 1).Font.Size
cellule.Font.Bold = code.Offset(0, 1).Font.Bold
Exit Sub
End If
Next
cellule.Interior.ColorIndex = Application.Range("Nontrouvé").Interior.ColorIndex
Fin:
End Sub