View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Color every 'nth' row?

Jack

If you want a macro............

Sub ColorEveryNthCell()
Dim rng As Range, i As Integer
Dim srng As Range
With ActiveSheet
On Error Goto EndAll
startrow = InputBox("Which Row to Start")
Set rng = Cells(startrow, 1)
everywhich = InputBox("How far apart")
numbrows = InputBox("How many times")
For i = 1 To numbrows - 1
Set prng = Union(rng, rng.Offset(everywhich * i, 0))
prng.EntireRow.Interior.ColorIndex = 3 ''Red
Next
End With
EndAll:
End Sub

Gord Dibben XL2002

On Sat, 6 Dec 2003 18:49:58 -0000, "Bob Phillips"
wrote:

Jack,

Could I suggest conditional formatting?

Select all the rows to apply to, including the in -between non-coloured
rows.
Goto menu FormatConditional Formatting
Change Condition 1 to FoprmulaIs
Input a formula of =MOD(ROW(),$A$1)=$B$1
Click the Format button
Select the pattern tab
Choose a colour
OK
OK

A1 holds the set size (your 4,17), and B1 is the row within that set to
colour. So A1=4, B1=2 will colour row, 6, etc. A1=3, B1 =1 colours 1,4,7.