Hello, am looking, yet again for assistance. I am trying to have cells change colour based on whether the entry is "1" (Red) or "2" (Green). So far my attempt (macro) has been unsuccessful, I used the following:
This did kind of do what I wanted, however as the column "I" (now columns "I&S") in question are fed from other sheets (1 of 7 Mon - Sun) depending on which day of the week is selected in D9). This data is obtained via an "=@indirect" to the relevant cell.
When I changed the day, the input values changed - yay!, however the colours remained as per the initial macro run (a mix of 1s in green and 2s in red) - boo hiss.
Running the macro again did correct the colours to the expected output, however although there were fewer input values than the first attempt, previously highlighted cells remained coloured even with no requisite text present.
What I am asking therefore is can anyone advise how best to achieve the desired result. If this makes any sense.
Snip shows the desired result in column "I" depending on whether the collected data is a 1 or a 2, I susbsequently added column "S" which should do the same as "I" but realised I have insufficient vba skills to write the desired code and trolling the internet failed to provide a solution.
Any and all help greatly appreciated. Thanks
VBA Code:
Sub FormatData()
Dim ws As Worksheet
Dim cell As Range
Set ws = ThisWorkbook.Sheets("Print for NoticeBoard")
For Each cell In ws.Range("I19:I" & ws.Cells(ws.Rows.Count, "I").End(xlUp).Row)
If cell.Value = "1" Then
cell.Interior.Color = RGB(255, 129, 129) ' Red
ElseIf cell.Value = "2" Then
cell.Interior.Color = RGB(153, 255, 153) ' Green
End If
Next cell
End Sub
When I changed the day, the input values changed - yay!, however the colours remained as per the initial macro run (a mix of 1s in green and 2s in red) - boo hiss.
Running the macro again did correct the colours to the expected output, however although there were fewer input values than the first attempt, previously highlighted cells remained coloured even with no requisite text present.
What I am asking therefore is can anyone advise how best to achieve the desired result. If this makes any sense.
Snip shows the desired result in column "I" depending on whether the collected data is a 1 or a 2, I susbsequently added column "S" which should do the same as "I" but realised I have insufficient vba skills to write the desired code and trolling the internet failed to provide a solution.
Any and all help greatly appreciated. Thanks