1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| ' Mise en couleur des cellules des feuilles de risques en aval
Public Sub setSeverity(CodeNameFeuilleActive As String, theColor As Long)
Dim Start As Boolean, i As Integer, CodeNameFeuilleRef As String, lastColorIndex As Long, FeuilleRef As Worksheet, Ref As Range, IntitSynthese As String, lastPattern As Long
' Par sécurité :
With ActiveCell
gRow = .Row
gCol = .Column
End With
Application.ScreenUpdating = False
Start = False
For i = 1 To 4
CodeNameFeuilleRef = "risk_" & i
If CodeNameFeuilleRef = CodeNameFeuilleActive Then Start = True
Set FeuilleRef = Conversion(ThisWorkbook, CodeNameFeuilleRef)
Set Ref = FeuilleRef.Cells(gRow, gCol)
If Not Start Then
lastColorIndex = Ref.Interior.ColorIndex
lastPattern = Ref.Interior.Pattern
End If
If Start Then
FeuilleRef.Unprotect
Ref.Interior.ColorIndex = Range(CodeNameFeuilleActive).Cells(theColor, 1).Interior.ColorIndex
Ref.Interior.Pattern = Range(CodeNameFeuilleActive).Cells(theColor, 1).Interior.Pattern
If DRisques.CBRisqueImportant Then
Ref.Interior.Pattern = Notice.Range("RisqueNonRenseigné").Offset(DRisques.LNiveau.ListIndex, 1).Interior.Pattern
End If
Protection FeuilleRef
End If
Next
' Report couleur dans la synthèse
Set FeuilleRef = Conversion(ThisWorkbook, "synthese")
Set Ref = FeuilleRef.Cells(gRow, gCol)
FeuilleRef.Unprotect
Ref.Interior.ColorIndex = Range(CodeNameFeuilleActive).Cells(theColor, 1).Interior.ColorIndex
Ref.Interior.Pattern = Range(CodeNameFeuilleActive).Cells(theColor, 1).Interior.Pattern
If DRisques.CBRisqueImportant Then
Ref.Interior.Pattern = Notice.Range("RisqueNonRenseigné").Offset(DRisques.LNiveau.ListIndex, 1).Interior.Pattern
End If
If lastColorIndex <> FeuilleRef.Cells(gRow, gCol).Interior.ColorIndex Or lastPattern <> FeuilleRef.Cells(gRow, gCol).Interior.Pattern Then
If CodeNameFeuilleActive = "risk_2" Then
IntitSynthese = "CI"
ElseIf CodeNameFeuilleActive = "risk_3" Then
IntitSynthese = "EC"
Else
IntitSynthese = ""
End If
FeuilleRef.Cells(gRow, gCol) = IntitSynthese
End If
Protection FeuilleRef
Application.ScreenUpdating = True
End Sub |