Hi all - I am having trouble with the following macros. What I am trying to get it to do is loop through all of the cells in my used range, and if there is a cell that is shaded red, then put true in the last column. It works when the cell is empty and shaded red, but if a cell has a value and is shaded red, it doesn't recognize it. Any help with this is greatly appreciated.
Also, I only need one red cell for the condition to be true - is there a way that once the condition is satisfied to force a move to the next row - or should I be checking rows instead of cells to make it faster?
Thanks again for any help.
Cheers.
Sub ColorCells()
Dim myRange As Range
Dim i As Long, j As Long
Dim LastCol As Integer
Range("IV1").End(xlToLeft).Select
LastCol = ActiveCell.column + 1
Cells(1, LastCol).Select
Selection.FormulaR1C1 = "Validation Error"
Set myRange = ActiveSheet.UsedRange
For i = 1 To myRange.Rows.Count
For j = 1 To myRange.Columns.Count
If myRange.Cells(i, j).Interior.ColorIndex = 3 Then
Cells(i, LastCol).Value = "True"
End If
Next j
Next i
End Sub
Also, I only need one red cell for the condition to be true - is there a way that once the condition is satisfied to force a move to the next row - or should I be checking rows instead of cells to make it faster?
Thanks again for any help.
Cheers.
Sub ColorCells()
Dim myRange As Range
Dim i As Long, j As Long
Dim LastCol As Integer
Range("IV1").End(xlToLeft).Select
LastCol = ActiveCell.column + 1
Cells(1, LastCol).Select
Selection.FormulaR1C1 = "Validation Error"
Set myRange = ActiveSheet.UsedRange
For i = 1 To myRange.Rows.Count
For j = 1 To myRange.Columns.Count
If myRange.Cells(i, j).Interior.ColorIndex = 3 Then
Cells(i, LastCol).Value = "True"
End If
Next j
Next i
End Sub