Conditional Highlighting Cells by Fiscal Quarters?

olimits7

Board Regular
Joined
Oct 29, 2004
Messages
229
Office Version
  1. 365
Platform
  1. Windows
Hi,

Please see below, currently I'm manually highlighting the colors based on different quarters starting from the "1st Inv. Date" as the "1st Month", I'm trying to see if there is a way this can be automatically updated using "Conditional Formatting".

So, as an example, taking the 09/01/23 invoice date; Q3 would fall under columns E, F, G and is highlighted in orange.

I was trying to set this up as 2 options:
  • Using a pull-down menu and depending on what quarter I select it will automatically highlight the appropriate cells.

  • Using conditional formatting, just set up different rules where it would highlight the correct cells in different colors representing the different quarters like I manually did below.

1699047974218.png


Thank you!
 
  • For some reason, if the invoice date is 11/01/22 it doesn't highlight the row at all for the correct Q1 month (April, May, June) sections.
Okay, so at least for my rules, it looks like I need to adjust them to handle the year as well, but I have updated them currently to handle no date in Column B, zero amounts in the cells, and Jan, Feb, Mar dates.

(XL2BB is not working on my 2013 version at home)

Q1:
Excel Formula:
=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q1"),D8<>0,MONTH($B8)+D$6>4,MONTH($B8)+D$6<=7))

Q2:
Excel Formula:
=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q2"),D8<>0,MONTH($B8)+D$6>7,MONTH($B8)+D$6<=10))

Q3:
Excel Formula:
=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q3"),D8<>0,MONTH($B8)+D$6>10,MONTH($B8)+D$6<=13))

Q4:
Excel Formula:
=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q4"),D8<>0,MONTH($B8)+D$6>13,MONTH($B8)+D$6<=16))

Thanks to awoohaw for the =IF(B8=""....) bit.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Ok, the final result is not pretty... I sure hope there is a nicer option, but see if this does what you want:

Edit: I'll keep playing with this because it is only effective through 12/1/23. No 2024 dates seem to work.

Book1 11-5-23.xlsx
ABCDEFGHIJKLMNO
1
2LEGEND
3ALLQ1Q2
4Q3Q4
5
6123456789101112
7Customer Name1st Inv. Date1st Month2nd Month3rd Month4th Month5th Month6th Month7th Month8th Month9th Month10th Month11th Month12th Month
87/1/2022100100100100100100100100100100100100
98/1/2022100100100100100100100100100100100100
109/1/2022100100100100100100100100100100100100
1110/1/2022100100100100100100100100100100100100
1211/1/20221001001001001001000100100100100100
1312/1/2022100100100100100100100100100100100100
141/1/2023100100100100100100100100100100100100
151001001001001001001001001000100100
163/1/2023100100100100100100100100100100100100
174/1/2023100100100100100100100100100100100100
186/1/20231000100100100100100100100100100100
197/1/2023100100100100100100100100100100100100
208/1/20231001001001001001000100100100100100
219/1/2023100100100100100100100100100100100100
2210/1/2023100100100100100100100100100100100100
2311/1/2023100100100100100100100100100100100100
2412/1/2023100100100100100100100100100100100100
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D8:O24Expression=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q4"),D8<>0,OR(ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=11.38,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=12.2,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=13.01)))textNO
D8:O24Expression=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q3"),D8<>0,OR(ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=8.94,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=9.76,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=10.57,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=18.85,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=19.67)))textNO
D8:O24Expression=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q2"),D8<>0,OR(ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=6.5,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=7.32,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=8.13,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=16.39,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=17.21,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=18.03)))textNO
D8:O24Expression=IF($B8="",FALSE,AND(OR($B$3="ALL",$B$3="Q1"),D8<>0,OR(ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=4.07,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=4.88,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=5.69,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=13.93,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=14.75,ROUND((INT(MONTH($B8)+D$6)/ROUNDDOWN($B8/365.25,0)*100),2)=15.57)))textNO
Cells with Data Validation
CellAllowCriteria
B3ListALL,Q1,Q2,Q3,Q4
 
Upvote 0
Okay, this has 2023 hard coded in the CF rules. You can probably automate that a bit better.

Mr Excel Questions 71.xlsm
ABCDEFGHIJKLMNO
7123456789101112
8Customer1st Inv Date1st Month2nd Month3rd Month4th Month5th Month6th Month7th Month8th Month9th Month10th Month11 Month12 Month
9Customer12023-Apr-01111222333444
10Customer22023-May-0111222333444FALSE
11FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
12Customer32023-Jun-011222333444FALSEFALSE
13Customer42023-Jul-01222333444FALSEFALSEFALSE
14FALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSEFALSE
15Customer52023-Aug-0122333444FALSEFALSEFALSEFALSE
16Customer62023-Sep-012333444FALSEFALSEFALSEFALSEFALSE
17Customer72023-Oct-01333444FALSEFALSEFALSEFALSEFALSEFALSE
18Customer82023-Nov-0133444FALSEFALSEFALSEFALSEFALSEFALSEFALSE
19
20
21Formula in cell C9=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3)),FALSE)
22
23123456789101112
24Customer1st Inv Date1st Month2nd Month3rd Month4th Month5th Month6th Month7th Month8th Month9th Month10th Month11 Month12 Month
25Customer12023-Apr-01100100100100100100100100100100100100
26Customer22023-May-01100100100100100100100100100100100100
272021-Jan-01100100100100100100100100100100100100
28Customer32023-Jun-01100100100100100100100100100100100100
29Customer42023-Jul-01100100100100100100100100100100100100
30100100100100100100100100100100100100
31Customer52023-Aug-01100100100100100100100100100100100100
32Customer62023-Sep-01100100100100100100100100100100100100
33Customer72023-Oct-01100100100100100100100100100100100100
34Customer82023-Nov-01100100100100100100100100100100100100
35
olimits7
Cell Formulas
RangeFormula
C9:N18C9=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3)),FALSE)
C21C21=FORMULATEXT(C9)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C9:N18,C23:N34Expression=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=1,FALSE)textNO
C9:N18,C23:N34Expression=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=2,FALSE)textNO
C9:N18,C23:N34Expression=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=3,FALSE)textNO
C9:N18,C23:N34Expression=IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=4,FALSE)textNO

Yes, this seems to work properly...Ty.

Currently, it highlights all quarters but is there a way to set up this conditional formatting to incorporate it so it works with a pull-down menu so I can have it show the way it does now but then also if I just want to see a specific quarter only I can change it to just show Q2, for example.

With the other formula that @dreid1011 provided I was able to get this to work with a combo pull-down menu by using the following below but I can't seem to figure out how to incorporate this into your formula.

Excel Formula:
=IF($B8="",,AND(OR($B$3=1,$B$3=2),MONTH($B8)+D$6>4,MONTH($B8)+D$6<=7))

=IF($B8="",,AND(OR($B$3=1,$B$3=3),MONTH($B8)+D$6>7,MONTH($B8)+D$6<=10))

=IF($B8="",,AND(OR($B$3=1,$B$3=4),MONTH($B8)+D$6>10,MONTH($B8)+D$6<=13))

=IF($B8="",,AND(OR($B$3=1,$B$3=5),MONTH($B8)+D$6>13,MONTH($B8)+D$6<=16))

Thank you.
 
Upvote 0
Ok, I think I was able to update your formula ( @awoohaw ) to work with a combo pull-dow menu by using the following; it seems to be working properly so I think I did this properly.

Excel Formula:
=AND(OR($A$1="ALL",$A$1="Q1"),IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=1,FALSE))

=AND(OR($A$1="ALL",$A$1="Q2"),IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=2,FALSE))

=AND(OR($A$1="ALL",$A$1="Q3"),IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=3,FALSE))

=AND(OR($A$1="ALL",$A$1="Q4"),IFERROR(IF(YEAR(EDATE($B9,-4+C$7))<>2023,FALSE, INT(((MONTH($B9)+C$7-2)-(IF(MONTH($B9)+C$7-2>14,12,0)))/3))=4,FALSE))
 
Upvote 0
If you're satisfied with what you have, I will stop trying to make this work. But I'll show you what I have currently. The 4 red outlined sections are technically within bounds of the formula, but need to be ruled out and I don't know how to exclude them right now. This incorporates a date entered in a cell to identify the current year as seen in D3.

1699239015536.png


And just for reference, these are the rules currently.
1699239169464.png
 
Upvote 0
If you're satisfied with what you have, I will stop trying to make this work. But I'll show you what I have currently. The 4 red outlined sections are technically within bounds of the formula, but need to be ruled out and I don't know how to exclude them right now. This incorporates a date entered in a cell to identify the current year as seen in D3.

View attachment 101511

And just for reference, these are the rules currently.
View attachment 101512

What you posted before seems to work great for my needs...Ty.

@dreid1011 and @awoohaw thank you both for your replies, both methods work well and I'm happy this works properly now with the conditional formatting and pull-down menu; it makes it a lot easier to view on the eyes! :) LOL.
 
Upvote 0
What you posted before seems to work great for my needs...Ty.

@dreid1011 and @awoohaw thank you both for your replies, both methods work well and I'm happy this works properly now with the conditional formatting and pull-down menu; it makes it a lot easier to view on the eyes! :) LOL.
Wonderful, and I am happy to help.
 
Upvote 0
Happy to help. I'm happy you found a solution here.

Best Wishes!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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