Hello,
I have a file which starts data in Cell E8 and continues down and to the right in varying columns in rows.
I created a macro to color certain data in the file yellow
I am now writing a macro to look at cells E8-E12, and if the cells contain 3 yellow colored cells, all 5 cells turn red.
This will continue through E13-E17 and also loop through all relevant columns that contain data.
In short starting at E8 it should check every 5 cells in a row for 3 colored data points. If there are three colored data points all 5 cells turn red.
I don't understand how to make my For statement jump down 5 columns for each loop. Could I have some advice?
Code
Sub FailCheck()
Dim Q As Variant
Dim ColorCounter As Integer
Dim lastrow As Long
Dim lastcolumn As Integer
Dim PCM As Integer
PCM = 5
lastrow = Range("E" & Rows.count).End(xlUp).Row
' Find the count of rows '
lastcolumn = Cells(1, Columns.count).End(xlToLeft).Column
' Find the count of columns '
For i = 5 To lastcolumn
For Each Q In Range("E & (8+5(i-4)):E" & lastrow).Offset(, i - 5)
If Q.Interior.Color = vbYellow Then
ColorCounter = ColorCounter + 1
If ColorCounter > 2 Then
Range("E8:E12").Interior.Color = vbRed
End If
MsgBox (ColorCounter)
End If
Next Q
Next i
End Sub
Display More