Alternate row coloring
I've written two routines, one to color the rows, the other to remove the color. I picked a
light gray for the shaded rows. Pick another color index value if you like by changing the
number 40 in this line
CI(1) = 40
to some another value.
Sub FaxIt()
Columns("A:A").AutoFilter Field:=1, Criteria1:="<"
ColorRows '<<<<<
Application.ActivePrinter = "Brother PC-FAX on BMFC:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Brother PC-FAX on BMFC:", Collate:=True
RemoveColor '<<<<<
Columns("A:A").AutoFilter
End Sub
Sub ColorRows()
Dim c As Range
Dim CI(0 To 1) As Long
Dim i As Long
Dim Rng As Range
CI(0) = xlColorIndexNone
CI(1) = 40
i = 0
Set Rng = ActiveSheet.UsedRange
Rng.Interior.ColorIndex = CI(i)
For Each c In Rng.Columns("A").SpecialCells(xlCellTypeVisible)
Rng.Rows(c.Row).Interior.ColorIndex = CI(i)
i = 1 - i
Next c
End Sub
Sub RemoveColor()
ActiveSheet.UsedRange.Interior.ColorIndex = xlColorIndexNone
End Sub
On Fri, 07 Nov 2003 12:40:51 -0800, David Turner wrote:
I've seen routines posted that color alternate rows in a range or sheet,
but I have a little different need.
I use the following routine a couple of times a month to fax in a food
order to a food distributing company. It filters out foods I don't need
from the list before faxing it.
Sub FaxIt()
Columns("A:A").AutoFilter Field:=1, Criteria1:="<"
Application.ActivePrinter = "Brother PC-FAX on BMFC:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Brother PC-FAX on BMFC:", Collate:=True
Columns("A:A").AutoFilter
End Sub
I would like the filtered list to have alternate row coloring.
Any help?
|