Is there, maybe, a faster method of cell referencing for conditional formatting?

code example:

For Each cell In irow
    For i = 1 To arr_size
        If cell > start(i) - arr1(i) And start(i) > Var1 And cell <= Var2 Then
            cell.Interior.ColorIndex = 22
            Exit For
        End If
    Next i
Next cell

1 Answers

1
Tim Williams On Best Solutions

Should be slightly faster:

Dim v, rng As Range

For Each cell In irow
    For i = 1 To arr_size
        If start(i) > Var1 Then
            v = cell.Value
            If v > start(i) - arr1(i) Then 
                If v <= Var2 Then
                    If rng Is Nothing then
                        Set rng = cell
                    Else
                        Set rng = aplication.union(rng, cell)
                    End If
                    Exit For
                End If
            End If
        End If
    Next i
Next cell

If Not rng Is Nothing then rng.Interior.ColorIndex = 22