Loop through a range cell by cell
Sub ColorCells1() Dim myRange As Range Dim i As Long, j As Long Set myRange = Range("A1:A5") For i = 1 To myRange.Rows.Count For j = 1 To myRange.Columns.Count If myRange.Cells(i, j).Value < 100 Then myRange.Cells(i, j).Font.ColorIndex = 3 Else myRange.Cells(i, j).Font.ColorIndex = 1 End If Next j Next i End Sub
1. | For Each Loops for a range | ||
2. | Set the value in a range by cell index | ||
3. | Loop through all cells in a range | ||
4. | Get Rows from a range | ||
5. | Get rows from a named range (name the range before running this cript) |