• Quicker way to examine ranges

    Author
    Topic
    #466705

    I have some code that looks through a range and determines if it falls within a certain time based on the state. If not, then it colors a row of cells. My states are in column C and my times are in columns N and O (as you can probably tell from the code below).

    It’s duplicated many times (almost every state) and the only variations are the state names and the times that determines the coloring.

    Below is a snippet for Georgia.

    Code:
    Dim N As Long
    For N = 2 To 1000
        If (Range("C" & N) = "Georgia" And Hour(Range("N" & N)) > 7 And Hour(Range("N" & N))  7 And Hour(Range("O" & N)) < 22) Then
            Range("A" & N & ":Z" & N).Interior.ColorIndex = 34
        End If
    Next N

    What I have works just fine, but I'm wondering if there is a quicker or more efficient way of doing this?

    Thanks in advance.

    Viewing 0 reply threads
    Author
    Replies
    Viewing 0 reply threads
    Reply To: Quicker way to examine ranges

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: