Colour alternate rows with unknown range

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi All

I want to change the color of the alternate rows starting from A3, but with unknown number of columns and rows. I have found the code below but I don't know how to apply to an unknown range, please could I have some advice?

Code:
Dim r As Range
    Set r = Range("A3:A20")
    Dim tmp As Range, i As Integer

    For Each tmp In r.Cells
        i = i + 1
        If i Mod 2 = 0 Then tmp.Interior.Color = RGB(127, 187, 199)
    Next tmp
 
Last edited:
Try:
Rich (BB code):
Cells(x, 2).Resize(, y-1).Formula = Replace("=SUM(B4:B@)", "@", x - 1)
 
Last edited:
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top