Microsoft Excel - row colouring

Asked By rana
05-Feb-11 12:54 PM
hi
i am trying to put the following formula to have row alternate colour but dos;t work i dont know why, plz can u send me one email with the attachment of this function
  olvin j replied to rana
05-Feb-11 02:00 PM
hi rana

Alternate Row Colors/Color Banding

Now that Excel has Conditional Formatting (since Excel 97) we can use it to create an alternate row color for a table of data. This is often referred to as color banding and means that every second row should be filled with a specified color.

How to: Alternate Row Colors/Color Banding

Let's say you have a table of data Starting in A1 and ending in D6. All you need to do is select the range A1:D6, Starting from A1, then go to Format>Conditional Formatting and choose "Formula is:" and then in the box to the right, type the formula as shown below;

=MOD(ROW(),2)

The MOD formula/function is used to return the remainder of a number (ROW()) after dividing it by a specified number, two (2) in this case.

The ROW formula/function will return the row number of the cell that houses it.

So the formula =MOD(ROW(),2) will only ever return 0 (zero) or 1. If you do not know already, 0 (zero) is equal to FALSE, while any number greater than 0 (zero) will equate to TRUE. When we use the "Formula is:" option of Conditional Formatting we must have a formula that returns only TRUE or FALSE. When TRUE, the format specified is applied. When FALSE, the format specified is not applied. With this in mind, we will return TRUE to all all rows where the row number divided by 2 equates to TRUE. Or, put another way, every second row.

Now click the "Format" button and choose your desired cell shading under "Patterns". Then "Ok" and "Ok" again.

Automatically Expand/Contract Alternate Row Colors/Color Banding

The simple method shown above is fine for a static table, but it will apply the format to all odd row numbers that do not yet have data. For example, we use the range A1:D6 but could use A1:D100 so that as our table has more data added the new row of data will be color coded automatically, while all unused rows will remain blank.

1) Select the A1:D100, Starting from A1.
2) Go to Format>Conditional Formatting and choose "Formula is:"
3) In the box to the right, type the formula as shown below;

=AND(MOD(ROW(),2),COUNTA($A1:$D1))

4) Click the "Format" button and choose your desired cell shading under "Patterns". Then "Ok" and "Ok" again.
Now only the used range of A1:D100 will have the alternate row color/banding.

Another way to do something very similar is to only include your used range in the initial selection, as we did at the Start , then go to Tools>Options-Edit and check the "Extend list formats and formulas". This will format new data added to the end of a list to match the format of the rest of the list. Formulas that are repeated in every row are also copied. To be extended, formats and formulas must appear in at least three of the five last rows preceding the new row.

How to: Alternate Row Colors/Color Banding 3D Effect

1) Select the A1:D100, Starting from A1.
2) Go to Format>Conditional Formatting and choose "Formula is:"
3) In the box to the right, type the formula as shown below;

=AND(MOD(ROW(),2),COUNTA($A1:$D1))

Note the absolute column and relative row reference: $A1:$D1
4) Click the "Format" button and choose your desired cell shading under "Patterns"
5) Click the "Border" page tab. Select Black under "Color", or Automatic if the default has not been changed. Now click on the solid black line at the bottom of the "Style" box. Click the bottom border of the box with the word "Text" in it and then click the right hand border.
6) Select White under "Color. Click the top border of the box with the word "Text" in it and then click the left hand border. It should look like below;

7) Click "Ok" then "Ok" again and you should see an effect like shown below;

Create New Account
help
showing just one Microsoft Excel Record at at time? Excel How can I show just one record at a time on the screen when using Microsoft Excel, vsn. 2002 Excel Discussions Microsoft Excel (1) Microsoft Excel vsn (1) John Walkenbach (1) Rows (1) You could hide all the
How do I get started using the Countif, Countifs option with Excel Excel Excel Worksheet Discussions Microsoft Excel (1) Excel (1) COUNTIF (1) MathurMicrosoft (1) Ryan (1) Bliengme (1) Columne (1) Caps (1) In A1 value in E2 In F1 = COUNTIF(a1:a10, "c", B1:B10, 5) count how many row have c in columne A and 5 in column B Now experiment ! best wishes - - Bernard V Liengme Microsoft Excel MVP http: / / people.stfx.ca / bliengme remove caps from email Hi, Kindly refer to
How Can I Sort Photos with the Other Data in Microsoft Excel? Excel I have text data in cells in my Microsoft Excel spreadsheet. I also have photo files in the spreadsheet. The photos files are associated with files. How can I get them to sort along with their associated text files? - - Newellmyra Excel Setup Discussions Microsoft Excel (1) Microsoft Excel spreadsheet (1) Format (1) Sort (1) Photo files (1) Text files (1
Filter in Microsoft Excel Excel Hi all, I am using microsoft excel 2000. I need help in filtering the data. I have two columns as below Name follows. b How we will define this filter. Please help me. . . . Thanx for reading. Robin Excel Worksheet Discussions Microsoft Excel (1) SUMPRODUCT (1) COUNTIF (1) OFFSET (1) COLUMN (1) VBA (1) À´ªàµà´¤àµ
reading .sxls files in Office XP 2002 Excel Excel Is there anyway I can allow my 2002 Excel to read .sxls files from the newer versions of Microsoft Excel? Excel Miscellaneous Discussions Office XP (1) Microsoft Excel (1) Office 2007 (1) Excel (1) Bliengme (1) Sxls (1) Caps (1) Docs (1) Hi