+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : change cell colour based on grouped values

  1. #1
    Registered User
    Join Date
    11-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Question change cell colour based on grouped values

    Hi guys,

    I'm new to this forum and hope I won't be disappointed :-)

    So to start with I have a spreadsheet with a few columns.

    I have grouped by one of the columns...which looks something like this:

    a
    a
    a
    a
    b
    b
    b
    b
    c
    c
    c
    d
    d
    e
    f

    Anyway, what I want to do is to have a different colour everytime the value changes (like i have shows above)...so all a's will be one colour, b's will be another, c's another etc...it will let me see easier where we only have 1, 2 or 3 rows (I expect to see 4). I don't mind if the colour alternates between two colours e.g Red and Yellow.

    I can't find what I'm looking for in conditional formatting (maybe I'm not looking hard enough!).

    Please help!

    Thanks

    ps - I am using Excel 2007
    Last edited by ismailm; 11-09-2011 at 12:38 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: change cell colour based on grouped values

    Assuming the data is in A2:A20 then select the range and go to Home|Conditional Formatting|New Rule.

    Select "use a formula to determine which cells to format" and enter formula like:

    =MOD(ROUNDUP(SUM(1/COUNTIF($A$2:$A2,$A$2:$A2)),0),2)=1

    click Format and choose a colour.

    This will alternate that colour and the default white....

    If want a colour other than white, you can add a conditional format with another similar formula

    =MOD(ROUNDUP(SUM(1/COUNTIF($A$2:$A2,$A$2:$A2)),0),2)=0

    and pick another colour...
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-09-2011
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    8

    Thumbs up Re: change cell colour based on grouped values

    You are a DON!!!

    Thanks ever so much...works perfectly! :-)
    Last edited by NBVC; 11-09-2011 at 12:06 PM. Reason: Deleted extraneous quote of whole post

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: change cell colour based on grouped values

    You are welcome.

    If you are satisfied with the solution provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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