Highlight row if column "D" contains year < 1/1/2023, organized subtotals...

cweaver

New Member
Joined
Jan 20, 2006
Messages
21
Office Version
  1. 365
Platform
  1. MacOS
Hi all,

I'm working with an Excel that I've organized into subtotals (thank you to Mr Excel for that!). I need a formula for doing the following:

1. I'd like to highlight the row (customer name) if:

- Column "D" (invoice date) for that customer contains a year less than 1/1/2023,
- and the customer should not contain any dates in 2023.

Here's some sample data:
1694796482113.png

1694796501706.png
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
FARMER BOYS*** Total
FARMER BOYS***159M8713933/28/23
FARMER BOYS***148M8441517/5/22
FARMER BOYS***159M8695162/15/23
FARMER BOYS***148M8337357/19/21
FARMER BOYS***141M83959711/4/21
FARMER BOYS***159M8428088/29/22
FARMER BOYS***147M8485794/5/22
FARMER BOYS***140M84281712/22/21
FARMER BOYS***140M8560142/9/22
FARMER BOYS***159M8713943/28/23
FARMER BOYS***159M8608768/10/22
FARMER BOYS***159M8695172/15/23
FARMER BOYS***162M8794756/6/23
FARMER BOYS***140M83547012/4/21
FARMER BOYS***140M8560152/9/22
FARMER BOYS***157M8624888/18/22
SENIOR LIVING ALHAMBRA VILLAS*** Total
SENIOR LIVING ALHAMBRA VILLAS***10M8577644/4/22
SENIOR LIVING ALHAMBRA VILLAS***10M8577654/4/22
SENIOR LIVING ALHAMBRA VILLAS***10M8443021/3/22
SENIOR LIVING ALHAMBRA VILLAS***10M8560512/11/22
PLEASANT VALLEY CORPORATION*** Total
PLEASANT VALLEY CORPORATION***94M8651585/22/23
PLEASANT VALLEY CORPORATION***94M8651535/22/23
PLEASANT VALLEY CORPORATION***94M8651575/8/23
PLEASANT VALLEY CORPORATION***93M8755265/11/23
PLEASANT VALLEY CORPORATION***90M8777535/15/23
PLEASANT VALLEY CORPORATION***90M8777605/17/23
PLEASANT VALLEY CORPORATION***94M8651555/8/23
PLEASANT VALLEY CORPORATION***13M8870241/30/23
PLEASANT VALLEY CORPORATION***01M8354922/4/22
PLEASANT VALLEY CORPORATION***01M8354932/3/22
PLEASANT VALLEY CORPORATION***01M8438012/3/22
PLEASANT VALLEY CORPORATION***01M8438022/3/22
PLEASANT VALLEY CORPORATION***01M8438032/3/22
PLEASANT VALLEY CORPORATION***01M8438042/3/22
PTI MANAGEMENT*** Total
PTI MANAGEMENT***38M8439648/6/22
PTI MANAGEMENT***38M7763505/1/18
PTI MANAGEMENT***38M7763515/1/18
PTI MANAGEMENT***38M7763525/1/18
PTI MANAGEMENT***38M7763535/1/18
PTI MANAGEMENT***38M7763545/1/18
PTI MANAGEMENT***38M7763555/1/18
PTI MANAGEMENT***38M8439388/6/22
PTI MANAGEMENT***38M8439518/6/22
PTI MANAGEMENT***38M8439528/6/22
PTI MANAGEMENT***38M8439638/6/22
PTI MANAGEMENT***38M7773096/15/18
PTI MANAGEMENT***38M7773106/15/18
PTI MANAGEMENT***38M7773116/15/18
PTI MANAGEMENT***38M7773126/15/18
PTI MANAGEMENT***38M7773136/15/18
PTI MANAGEMENT***38M7778176/15/18
 
Upvote 0
Select the range from cell A1 to the last row with data in column D, then go to Conditional Formatting, enter this Conditional Formatting formula, and select your desired color:
Excel Formula:
=AND($D1<>"",YEAR($D1)<2023,COUNTIFS($A:$A,$A1,$D:$D,">="&DATEVALUE("1/1/2023"))=0)

Here is what the first 25 rows of your example look like with this:
1694797236515.png
 
Upvote 0
Thanks for the quick reply...which option under conditional formatting do I choose?

Screenshot 2023-09-15 at 1.15.17 PM.png
 
Upvote 0
You need to click "New Rule" (as you are creating a new rule!).
Then, after that, select the "Use a formula to determine which cells to format" option.
That is where you enter in the formula I gave you, and then select your desired formatting option/color.

1694798794624.png
 
Upvote 0
That does not look like the formula I gave.
What was the exact range you selected before you pasted in the formula I gave you?
 
Upvote 0
This is the formula listed above...

=AND($D1<>"",YEAR($D1)<2023,COUNTIFS($A:$A,$A1,$D:$D,">="&DATEVALUE("1/1/2023"))=0)

A1 through D9002
 
Last edited:
Upvote 0
Please answer the question I asked, this is critical to debugging your issue:
What was the exact range you selected before you pasted in the formula I gave you?

When writing a Conditional Formatting formula for a multi-cell range, you need to write the formula as it pertains to the very first cell in your selected range.
As long as you use the absolute/relative range references correctly, Excel will automatically adjust it for all the other cells correctly.

As I said, I wrote the formula as it pertains to cell A1.
If cell A1 is NOT the first cell in the range you selected before entering my formula, it will not work properly - all the range references will be off.
If you are starting in some other cell, I need to know what it is so we can adjust the formula appropriately.

So unless you are comfortable trying to modify that yourself, you will need to provide me with that information.
 
Upvote 0
Sorry about that it's actually

A2 through D9002 That's the top of the Excel...

Screenshot 2023-09-15 at 2.11.14 PM.png
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,688
Members
449,179
Latest member
kfhw720

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top