Conditional formatting question

HistProf 20 Reputation points
2025-07-16T14:51:42.6866667+00:00

I have a large dataset I need to review (1000+ rows). Each row contains about a dozen columns, one of which is the name of an individual. I need to check the information for each individual, and I'd like to use conditional formatting to help me do this by making all rows for each individual a color that's distinctive from the rows above and the rows below. Below there are so many individuals (several hundred), I cannot create a conditional formatting formula in which I manually enter the values for formatting.

Here is how I would like this to look:

In this example, I've used alternating colors, but a range of colors is fine. What matters is that color change will enable me to more easily tell the difference between each person.

Microsoft 365 and Office | Excel | For education | MacOS
0 comments No comments
{count} votes

Answer accepted by question author
  1. HansV 462.3K Reputation points MVP Volunteer Moderator
    2025-07-16T15:17:16.8833333+00:00

    Select A2:L1200 or so (include more columns and rows if needed).

    The active cell in the selection should be in row 2.

    In the following I'll assume that the name is in column A.

    On the Home tab, click Conditional Formatting > New Rule.

    In the Style box, click Classic.

    Under the Classic box, select 'Use a formula to determine which cells to format'.

    Enter the formula

    =ISODD(COUNTA(UNIQUE($A$2:$A2)))

    On the Format with box, click custom format.

    In the Format Cells dialog box, activate the Fill tab.

    Select a color.

    Click OK until the dialog boxes are closed.


3 additional answers

Sort by: Most helpful
  1. HistProf 20 Reputation points
    2025-09-01T16:31:27.8133333+00:00

    Unfortunately, this did not work. It only formatted a few rows, and not in the pattern I need. Let me provide an example here of how I want this to look. Perhaps this will help.

    Rows 1-3 (not counting the header row) should have a red fill. Rows 4-7 should have a green fill. Rows 8-9 should have a red fill. And so on. the goal is to use the alternating fill color to mark when the categories change. The formula you provided did not work, either for Excel on my Apple desktop or online with Office 365. Is there another way to do this?

    Thanks.

    Heading Category 1 Subcategory1
    1 Fruit Apples
    1 Fruit Apples
    1 Fruit Oranges
    1 Fruit Strawberry
    2 Meat Beef
    2 Meat Chicken
    2 Meat Pork
    2 Meat Fish
    1 Grain Rice
    1 Grain Corn
    0 comments No comments

  2. HansV 462.3K Reputation points MVP Volunteer Moderator
    2025-09-01T18:21:19+00:00

    Like this? I used column B as the "identifier" column this time.

    User's image

    Sample workbook: AlternatingColor.xlsx

    0 comments No comments

  3. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2025-09-01T23:15:03.9033333+00:00

    Hi,

    Using this formula, you will have to write different rules because there are different colours

    =COUNTA(UNIQUE($B$2:$B2))

    So you will have to check that if the result is 1, then colour to Green, if it is 2, then red etc.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.