Geacht forum,
onderstaande macro verandert de cel kleur als daar een bepaalde waarde in staat.
Deze macro wordt opgestart bij het openen van de sheet.
Nu wil ik dat de aangegeven celkleuren ook veranderen op het moment dat er een waarde in de cel veranderd wordt.
Kunt u mij helpen?
mvg,
Aat
onderstaande macro verandert de cel kleur als daar een bepaalde waarde in staat.
Deze macro wordt opgestart bij het openen van de sheet.
Nu wil ik dat de aangegeven celkleuren ook veranderen op het moment dat er een waarde in de cel veranderd wordt.
Kunt u mij helpen?
mvg,
Aat
Code:
Sub CondFormatTracker()
Dim c, acc, cpe, pe, cimp, rfs As Range
Dim col_interior As Integer
Dim lastRow As Integer
lastRow = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
Set acc = Range("Q6", "S" & lastRow)
Set cpe = Range("T6", "V" & lastRow)
Set pe = Range("W6", "X" & lastRow)
Set cimp = Range("Y6", "AD" & lastRow)
Set rfs = Range("AE6", "AH" & lastRow)
col_interior = 35
For Each c In acc
GoSub Colors
Next c
col_interior = 20
For Each c In cpe
GoSub Colors
Next c
col_interior = 28
For Each c In pe
GoSub Colors
Next c
col_interior = 37
For Each c In cimp
GoSub Colors
Next c
col_interior = 17
For Each c In rfs
GoSub Colors
Next c
GoTo EndSub
Colors:
If InStr(c.Value, "Delivered") Then
c.Interior.ColorIndex = 4
c.Font.ColorIndex = 1
ElseIf InStr(c.Value, "Planned") Then
c.Interior.ColorIndex = 23
c.Font.ColorIndex = 1
ElseIf InStr(c.Value, "Ordered") Then
c.Interior.ColorIndex = 15
c.Font.ColorIndex = 1
ElseIf InStr(c.Value, "Failed") Then
c.Interior.ColorIndex = 3
c.Font.ColorIndex = 2
ElseIf InStr(c.Value, "Attention") Then
c.Interior.ColorIndex = 3
c.Font.ColorIndex = 2
Else
c.Interior.ColorIndex = col_interior
c.Font.ColorIndex = 1
End If
Return
EndSub:
End Sub