+ Reply to Thread
Results 1 to 14 of 14

Color rows based on Value above

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Color rows based on Value above

    I'm sorry; I'm down with some type of sinus sickness, so my brain isn't working right, otherwise I'm sure I could figure this out. I want to color each row in my spreadsheet if the value in column C matches the value of column C above or below it. I know how to color the rows, but I'm drawing a blank on how I'd set up the
    Please Login or Register  to view this content.
    We're talking about 14000 lines, and in that range there are 6000 unique values.

    Thanks in advance for any help on this.
    Last edited by jomili; 11-23-2011 at 11:32 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Color rows based on Value above

    Hi,

    Just use a conditional format with the following 'Formula Is' option

    Please Login or Register  to view this content.
    and apply it to however many cells/rows you want, e.g. $A$2:$Z$100
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    That doesn't quite get it. It's highlighting the duplicate items, but it's also highlighting one row above those duplicates and one row below. See the example attached.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    I found a VBA approach, but need some help refining it. Here's how it exists so far:
    Please Login or Register  to view this content.
    My problem on this is that the macro was originally written to highlight only the cell, but I want it to highlight the row from the first column to the last column used, hence I have those variables in place, but don't know how to use them to replace the line:
    Please Login or Register  to view this content.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Color rows based on Value above

    Hi,

    Forget the first And condition, I didn't know whether you had blanks in your rows.

    Use instead the cond. format

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    Richard,

    It's still not working correctly. See the picture.
    Attached Images Attached Images

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

    Re: Color rows based on Value above

    Richard's solution works.

    Delete all the CFs you have in the range and start fresh.

    Select from A2:C105 and apply formula:

    =OR($C1=$C2,$C3=$C2)
    Attached Files Attached Files
    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.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Color rows based on Value above

    You added it incorrectly (the formula assumed you had a cell in row 2 active when you did it) so the rows being compared were off by one. See attached.
    Attached Files Attached Files
    Remember what the dormouse said
    Feed your head

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    Okay, so it seems I need to select my used range not counting the header range and apply the formula to that to highlight all of my data on the rows with duplicate data in column C. So, to set it up via macro I guess I'd do this:
    Please Login or Register  to view this content.
    do you see anything else I'd need to add to my code to make this a reusable macro?
    Last edited by jomili; 11-23-2011 at 10:13 AM.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Color rows based on Value above

    The formula would be wrong if the usedrange does not start in row 1

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    So if the used range started on Row 3, the formula would need to be
    Please Login or Register  to view this content.
    , right?

    How would I do it to make the formula variable depending on what the first row is?

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: Color rows based on Value above

    Something like this, using R1C1 format:
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    Thanks for catching that. Here's my updated macro in case anyone else can benefit from it.
    Please Login or Register  to view this content.

  14. #14
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,955

    Re: Color rows based on Value above

    Changed it to do away with the selection. Also refigured the used range (I was getting colors in deleted columns).
    Please Login or Register  to view this content.

+ 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