+ Reply to Thread
Results 1 to 10 of 10

Excel 2007 : Highlight every other group of rows

  1. #1
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Highlight every other group of rows

    I’m trying to take a table of duplicate information and highlight every other row with a light grey highlight just so it’s easier to see the individual groups. The duplicate data is sorted and in column A and the other columns will have varying bits of data. sometimes there are 2 duplicate values and sometimes there are 3, maybe even 4.

    In the example below, the rows with 12345 data should be light gray along with the 98765 rows

    Please Login or Register  to view this content.
    Last edited by JimDandy; 01-20-2010 at 03:04 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,698

    Re: Highlight every other group of rows

    Hello Jim,

    lets say your data is in A1:D100.

    Select that range and apply conditional formatting with the following formula

    =MOD(SUM(1/COUNTIF($A$1:$A1,$A$1:$A1)),2)

    apply formatting as required

  3. #3
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Highlight every other group of rows

    It looks like it tries to highlight the rows but after the first couple groups, it stops getting accurate about the grouping.
    Last edited by JimDandy; 01-20-2010 at 01:00 AM.

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,698

    Re: Highlight every other group of rows

    Ah, sorry Jim, yes I tested it further and I got the same scenario, problem is with some small "rounding errors" with MOD which throw the calculation out. As you have Excel 2007 you can use this version which utilises ISODD function

    =ISODD(SUM(1/COUNTIF($A$1:$A1,$A$1:$A1)))

    Note: that won't work in Excel 2003 or earlier because ISODD, in those versions, is an Analysis ToolPak add-in function that can't be used in conditional formatting. If you want a version compatible with Excel 2003 then you can add in a ROUND function to my original suggestion, i.e.

    =MOD(ROUND(SUM(1/COUNTIF($A$1:$A1,$A$1:$A1)),0),2)

  5. #5
    Forum Contributor
    Join Date
    11-17-2004
    MS-Off Ver
    Office 2016
    Posts
    527

    Re: Highlight every other group of rows

    Aces! This was the solution...many thanks!

  6. #6
    Registered User
    Join Date
    04-09-2013
    Location
    New York, US
    MS-Off Ver
    Excel:mac 2011
    Posts
    1

    Re: Excel 2007 : Highlight every other group of rows

    I implemented using:

    =ISODD(SUM(1/COUNTIF($A$1:$A1,$A$1:$A1)))

    And it *looks* like it worked (I have almost 900 rows), but it took about 15 minutes to get all the highlighting done and now when I try to scroll or do anything, Excel suddenly grabs about 98% of my cpu and won't respond.

    Thoughts?

  7. #7
    Registered User
    Join Date
    03-08-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Excel 2007 : Highlight every other group of rows

    Can someone help explain the rounding issues?

    ISODD worked for me when MOD did not,

    but on another tab, using the same formula, it gets wrong after a few rows.

    Is there something more "precise?" than ISODD?

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Excel 2007 : Highlight every other group of rows

    sako...Welcome to the Forum.

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  9. #9
    Registered User
    Join Date
    11-14-2013
    Location
    toronto, ontario
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Excel 2007 : Highlight every other group of rows

    I have the same problem, except that instead of column A the data that the cells will be grouped by is in column C. i tried just replacing all the A's with C's but that didn't work. Is anyone able to explain this formula?

    Thanks

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Excel 2007 : Highlight every other group of rows

    Fiona, please read what I posted in post 8...right above your post!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1