Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50057

Macro hangs up in formatting loop

$
0
0
I have a report that I am trying to automate and I have run into a snag in getting the formatting to work. I am trying to alternate row color to make it a bit easier to read but it seems to want to hang up in the loop. Here is the code I am running, I don't see what I am doing wrong, and would appreciate any suggestions.

Code:

Sub test()

    If Cells(12, 4) > 0 Then
        Set m = Range(Cells(12, 6), Cells(12, 6).End(xlDown))

        For Each f In m
            If f.Row Mod 2 = 0 Then 'Khaki
                Range(f, f.End(xlToRight)).Cells.Interior.Color = RGB(225, 205, 175)
                    Else            'Light Khaki
                Range(f, f.End(xlToRight)).Cells.Interior.Color = RGB(255, 235, 205)
            End If
        Next f
    End If

End Sub

Thanks!

Viewing all articles
Browse latest Browse all 50057

Trending Articles