Forum Discussion
ONG ZHEN YANG RP
May 18, 2018Brass Contributor
Needs Help Editing a Simple Code
I am creating a code that would make all odd rows yellow and all even rows white It's not working properly right now so I would appreciate any help editing it! The error is that the subscript is out...
Matt Mickle
May 18, 2018Bronze Contributor
This is a little bit simpler then what you have. Instead of looping through the cells individually one at a time you can just color the whole row at once.
Note: Column T is Column # 20
Sub loops_exercise() Dim R As Integer For R = 1 To 20 If R Mod 2 = 0 Then Range("A" & R & ":T" & R).Interior.Color = vbWhite Else Range("A" & R & ":T" & R).Interior.Color = vbYellow End If Next R End Sub