Alternate Row Color Style

F

freem123

Hi,

This is my very first post to this site, and I'm pretty stoked.

So I want to set up a new style to allow me to alternate row shading.
I have been using the following to alternate row shading:

1.Select the range that you want to format
2.Choose Format, Conditional Formatting
3.In the Conditional Formatting dialog box, select Formula Is from
the drop-down list, and enter this formula:=MOD(ROW(),2)=0.
4.Click the Format button, select the Patterns tab, and specify a
color for the shaded rows.
5.Click OK twice to return to your worksheet.

Now I want to make this a style so I don't have to continuosly cut and
paste this formula to each sheet.

Please help me and show what a guru you are.
 
P

Peo Sjoblom

You can format the workbook to your liking and save it as a template *.xlt,
then when you need it just do file>new>general templates and select it. I
don't think you can use conditional formatting in a style


--

Regards,

Peo Sjoblom

http://nwexcelsolutions.com
 
G

Guest

I created a macro to do this.
This colors lines 4,8,12,... one color
and lines 2,6,10,... another color
I ended up not using Fmt1, but left it in for possible future use.
===================================
Public Sub HighlightRows2()

Dim Cntr As Integer
Dim Fmt1 As Variant
Dim oFC As FormatCondition

Fmt1 = "=NOT(MOD(ROW(),4))"

With ActiveSheet.Cells

For Each oFC In .FormatConditions
''' MsgBox " Type=" & oFC.Type
''' Select Case oFC.Type
''' Case xlCellValue
''' Case xlExpression
''' MsgBox " type form=" & TypeName(oFC.Formula1)
''' MsgBox " Form1=" & oFC.Formula1
''' Case Else
''' MsgBox "ofc.type else"
''' End Select
.FormatConditions(1).Delete
Next oFC

With .FormatConditions
With .Add(Type:=xlExpression, Formula1:="=NOT(MOD(ROW(),4))")
.Interior.ColorIndex = 38
End With
With .Add(Type:=xlExpression, Formula1:="=NOT(MOD(ROW()+2,4))")
.Interior.ColorIndex = 34
End With
End With

End With

End Sub
============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top