PDA

View Full Version : Color Rows or Colums



ch4nk1ngm1ng
03-12-2009, 01:14 PM
Is there a simple macro program so that when it is executed on sheet, it will color all the cells in every 5th row/column in grey?

Bob Phillips
03-12-2009, 01:19 PM
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow Step 5

.Rows(i).Interior.ColorIndex = 15
Next i

ch4nk1ngm1ng
03-12-2009, 01:27 PM
Thanks for the formula. I can't seem to make it run. Does it matter that I have excel 2003?

BrianMH
03-12-2009, 01:28 PM
do you have any data in column a?

ch4nk1ngm1ng
03-12-2009, 01:35 PM
No data, was testing it on a blank sheet. Thanks, it works.

mdmackillop
03-12-2009, 02:14 PM
You can also use Mod
For i = 1 To 500
If i Mod 5 = 1 Then Rows(i).Interior.ColorIndex = 15
Next

Chris Bode
03-12-2009, 10:13 PM
Dim row As Long, col As Long
For row = 1 To Sheet1.Rows.Count Step 5
For col = 1 To Sheet1.Columns.Count Step 5
Sheet1.Cells(row, col).Interior.Color = 12632256
Next
Next