简体   繁体   中英

Excel formatting/Highlight row based on the last date and equal cell value

My question relates with the following.

I have a matrix in Excel of values, I want to highlight the entire row if two conditions are met. Those conditions are:

a. For equal values on column A compare its date;

b. If the value is equal, highlight the row with the most recent date.

Graphically its the following:

    A   B
1   Y   04-08-2006

2   X   02-07-2008

3   X   12-05-2014

4   Z   09-08-2014

5   X   25-06-2016

6   Z   01-04-2018

7   Y   24-07-2018

8   X   25-09-2018

I want to highlight the 6, 7 and 8 row with different colors.

Can I do that with conditional formatting or its not possible and the only way is to write code in VBA?

Thank you.

You don't need VBA for this. Make a small Pivot table where your column A is the rows and columns B are the values set to max. Then add a columns that is a vlookup to add the max date for each group (formula show in image) and finally just add conditional formatting, one rule per group again as shown in the image (note in this case the formatting is applied to the range A1:C9

在此处输入图片说明

You can always hide column D and the pivot table or put them on another sheet if need be.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM