Hey guys, finishing up a project of mine and I'm needing some more VBA help. i've got the code below:
What im needing to do is to have the macro look at my variable range (Starting on column H going on to a user defined column) row by row and to add a "Final" column at the end of the dataset. Each cell in the final column will have content dependent on the Color of the cells in the dataset for each corresponding row. IE if row 2 has a single cell in it that is red, then my final cell will need to be red and state "DQ". Otherwise if any row has 1 or more yellow cells but NO RED cells then its final cell must be labeled "REVIEW" and be colored yellow. Furthermore if any row contains NO RED, NO YELLOW, and at least 2 GREEN, then it would need to result in a green QUALIFIED end result. I believe im on the right track with the code above but its not quite there.
Code:
Sub finalizer()
Dim lstrow As Long, lstcol As Long, x As Integer, y As Integer
Range("A1").Select
Selection.End(xlToRight).Offset(0, 2).Select
Selection.End(xlToRight).Offset(0, 2).Select
y = ActiveCell.Column
lstrow = ActiveSheet.UsedRange.Rows.Count
lstcol = ActiveSheet.UsedRange.Columns.Count
x = 2
Dim c As Range
Do While x <= lstrow
For Each c In Selection
'DQ
If c.Interior.ColorIndex = 3 Then
ActiveCell.FormulaR1C1 = DQ
ActiveCell.ColorIndex = 3
x = x + 1
'Review
ElseIf (c.Interior.ColorIndex <> 3) And (c.Interior.ColorIndex = 6) Then
ActiveCell.FormulaR1C1 = REVIEW
ActiveCell.ColorIndex = 6
x = x + 1
'Qual
Else
ActiveCell.FormulaR1C1 = QUALIFIED
ActiveCell.ColorIndex = 4
x = x + 1
'Exit For
End If
Next c
Loop