Zebra lines, highlighting applied to alternative rows is a very good way to make tables readable & pretty.
We can use either conditional formatting or table formats to quickly add zebra lines to our data.
But what if you want a little more?
What if you want to highlight, lets say 3 rows in one color and 3 in another and repeat this …
Of course, we can use conditional formatting and come-up with some clever mix of ROW & MOD. But why waste so much of creative sauce on something as trivial as zebra line? So here is a quick alternative.
Use Table styles and tell excel how you want to highlight the lines.
Steps to create custom zebra lines
- First convert your data to table, if you have not already done it.
- Now, go to Table Design ribbon and right click on the table style you want and choose duplicate
- Excel creates a duplicate table style and opens a box to edit it.
- Give it a friendly name like myTableStyle1 or zebra-v1
- Select “First Row Stripe” and set stripe size to 2 or 3 as you want.
- Repeat the step for “Second Row Stripe” as well.
- Click OK & save your style.
- And now, apply this style to your table by selecting it from Table styles gallery.
- Your custom zebra is ready to bray and jump around.
Bonus tip #1: You can have 2 different stripe sizes too
For example you can have 5 rows for first stripe and 2 for second stripe, thus highlighting weekends in a different color.
Bonus tip #2: You can apply the same to columns too
You can apply the same concept to column stripes (banded columns) and set their sizes using table styles.
Bonus tip #3: Turn on / off zebra lines with a click
If you ever feel tired looking at all the stripes, you can quickly turn them off /on from Design Ribbon > Banded Rows
Homework: Change color when value changes
When you have few values with some duplicates, it makes sense to apply a band color whenever there is a change in value. How to set up zebra lines then? See here for your homework.
[Related: Zebras & Checker boards using Excel]
Do you use custom table styles?
Custom table styles are an easy way to tell Excel how we want our data to look. I use them often when designing a report or spreadsheet model.
What about you? Do you use custom styles? Have you tried the stripe size feature? What is your experience like? Please share using comments.
14 Responses to “Customize Zebra lines Quickly using Table Styles [tip]”
Thanks for the tip. Having just switched over to 2007 from 2003 within the past year, I know there's lots of cool features that I'm simply not aware of, and tables and all their functions/features are certainly one of them. Thanks for all the great articles you've done talking about tables.
for some reason can't get this to work for me. After pressing okay and then. It just stays as it was.Any advice? tks
Did you apply the style after creating it?
go to design--> table styles and click on the style u created
This is so spooky - I had this issue come up yesterday, but I need to highlight every alternate 200 rows - for batch emailing - any way to do this?
@Carolanne
I would use a Conditional Format formula of: =ISEVEN(INT(ROW()/200)+1)
Thanks Hui - but I'm an idiot - would this be a conditional formatting rule? I can't get it to work:(
@Carolanne
Yes, Its a CF rule
I would ensure that you delete all CF rules first
If that doesn't help can you email me the file
It worked - thank you!
use some VBA e.g. routine FormatResults
Sub AlternateRowColors(rTmp As Range)
Const iEven% = 1 'colour rows (1 even, 0 odd)
Const iStartRw% = 0
Const iGrpRw% = 200 'block rows
rTmp.Interior.ColorIndex = xlNone ''color to preference or remove
For Each rCell In rTmp.Rows ''change range accordingly
If (rCell.Row - iStartRw) Mod iGrpRw * 2 < iGrpRw Then rCell.Interior.ColorIndex = 15 ''color to preference
Next rCell
End Sub
Sub FormatResults()
Dim rTmp As Range
Set rTmp = Sheet1.[A19].CurrentRegion
AlternateRowColors rTmp
End Sub
Thanks for the tip. Is it possible to save custom table design so that they can be applied to other tables?
This is a great tip! I haven't tried customizing the table feature styles and will give it a try. There is still value in using the ROW and MOD combination if you want to dynamically alternate which other rows you want to shade (i.e. every 3rd or 4rth row). This video shows how http://youtu.be/FFnCnClSv1U.
[...] More on this tip: Customize banded rows / columns in tables [...]
I have created an Excel 2010 pivot table using a flattened table from the powerpivot menu. For some reason, banded rows do not get displayed. I have tried the custom zebra lines and even after the custom settings are applied, the rows remain unformatted.
Is there another setting that overrides the banded rows?
Thanks.
@Brian
Can you upload / email me the file ?