Excel conditional formatting in a Gantt Chart

mb8marmed

New Member
Joined
Feb 15, 2020
Messages
11
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I was trying to provide conditional formatting in my Gantt Chart. However, I have difficulty developing a formula that will trigger to highlight the cell or range, as the date is not a usual one. I'm hoping that someone from this group can help me solve the issue. I manually provided the colors for visualization, and the conditional formatting is supposed to work on this, but it's not working the way I wanted.

Thank you in advance.



Cell Formulas
RangeFormula
G1:M1,R1:AP1G1=IF(AND(MONTH(G$4)=MONTH($D6),AND($D6<=G$4*G$14*13,$D6<G$4)),"x","")
G2G2=T4
G3,J3,M3,P3,S3,V3,Y3,AB3,AE3,AH3,AK3,AN3G3=H4
G4G4=IF(MONTH(D1-WEEKDAY((D1),2)+1)<MONTH(D1),(D1-28-DAY(D1)+7)-WEEKDAY((D1-DAY(D1)+7),2)+1,(D1-DAY(D1)+7)-WEEKDAY((D1-DAY(D1)+7),2))
H4:AP4H4=IF(G4+13>EOMONTH(G4,0),EOMONTH(G4,0)+1,G4+13)
F5:F13F5=IF(AND(D5<>"",E5<>""),E5-D5,"")
G5:AP13G5=IF(AND(MONTH(G$4)=MONTH($D6),AND($D6<=G$4*G$14*13,$D6<G$4)),"x","")
D6D6=MIN(D7:D12)
E6E6=MAX(D7:D12)
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
If you want 2 colors then you need 2 rules:

Dante Amor
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAP
1Start Date01/01/2022
22022
3JanFebMarAprMayJunJulAugSepOctNovDec
4#ActivityStartEndDays02-ene15-ene28-ene01-feb14-feb27-feb01-mar14-mar27-mar01-abr14-abr27-abr01-may14-may27-may01-jun14-jun27-jun01-jul14-jul27-jul01-ago14-ago27-ago01-sep14-sep27-sep01-oct14-oct27-oct01-nov14-nov27-nov01-dic14-dic27-dic
5
61Activity 102-mar-2221-sep-22203
7aSub-Activity 1.202-mar-22
8bSub-Activity 1.305-abr-22
9cSub-Activity 1.415-may-22
10dSub-Activity 1.530-jun-22
11eSub-Activity 1.610-ago-22
12fSub-Activity 1.721-sep-22
Hoja1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G6:AP12Expression=OR(AND(G$4>=$D6,G$4<=$E6),AND($D6>=G$4,$D6<=H$4,$E6<>""))textNO
G6:AP12Expression=OR(AND(G$4>=$D6,G$4<=$E6),AND($D6>=G$4,$D6<=H$4))textNO
 
Upvote 0
If you want 2 colors then you need 2 rules:

Dante Amor
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAP
1Start Date01/01/2022
22022
3JanFebMarAprMayJunJulAugSepOctNovDec
4#ActivityStartEndDays02-ene15-ene28-ene01-feb14-feb27-feb01-mar14-mar27-mar01-abr14-abr27-abr01-may14-may27-may01-jun14-jun27-jun01-jul14-jul27-jul01-ago14-ago27-ago01-sep14-sep27-sep01-oct14-oct27-oct01-nov14-nov27-nov01-dic14-dic27-dic
5
61Activity 102-mar-2221-sep-22203
7aSub-Activity 1.202-mar-22
8bSub-Activity 1.305-abr-22
9cSub-Activity 1.415-may-22
10dSub-Activity 1.530-jun-22
11eSub-Activity 1.610-ago-22
12fSub-Activity 1.721-sep-22
Hoja1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G6:AP12Expression=OR(AND(G$4>=$D6,G$4<=$E6),AND($D6>=G$4,$D6<=H$4,$E6<>""))textNO
G6:AP12Expression=OR(AND(G$4>=$D6,G$4<=$E6),AND($D6>=G$4,$D6<=H$4))textNO

Hi Mr. DanteAmor,

Thanks for the inputs, I tried your formula and expanded the chart, and it is almost there. However, at some point the formula "=OR(AND(G$4>=$D6,G$4<=$E6),AND($D6>=G$4,$D6<=H$4))", for the light blue color is not behaving properly for some dates such as:

01-Jan-2022
28-Jan-2022
01-Mar-2022
03-Mar-2022

Maybe you can help me on this. Thank you so much for the help.

mb8marmed

 

Attachments

  • Formatting formula-17082023.png
    Formatting formula-17082023.png
    53.4 KB · Views: 8
Upvote 0
Change that formula for this:
Excel Formula:
=OR(AND($D6>=G$4,$D6<H$4),AND($D6<$G$4,G$4=$G$4),$D6=G$4)

🫡
Hi DanteAmor,

The code is now working properly and speeds up my work significantly.

Thank you so much...
 
Upvote 0
Hi DanteAmor,

The code/formula for the light blue conditional formatting is working perfectly. Maybe you can help me to correct the formula for the dark blue conditional formatting.
=OR(AND(G$4>=$D5,G$4<=$E5),AND($D5>=G$4,$D5<=H$4,$E5<>""))

Additionally, if you can also provide a formula for the conditional formatting that will create border in the column once the TODAYS() date is within the range of the week as seen on the attachment.

Thank you and more power.
 

Attachments

  • Gantt Chart for Query.png
    Gantt Chart for Query.png
    58.5 KB · Views: 4
Upvote 0
=OR(AND(G$4>=$D5,G$4<=$E5),AND($D5>=G$4,$D5<=H$4,$E5<>""))
In your image there is no data in the cells of row 5, but in the formula that you put, you refer to cells of row 5 :unsure:

----- --

Maybe you can help me to correct the formula for the dark blue conditional formatting
I did other tests for the dark blue, try:
Excel Formula:
=OR(AND($E6<>"",G$4>=$D6,G$4<=$E6),AND($E6<>"",$D6>=G$4,$D6<H$4))

----- --
if you can also provide a formula for the conditional formatting that will create border in the column once the TODAYS() date is within the range of the week
Try:
Excel Formula:
=AND(TODAY()>=G$4,TODAY()<H$4)

😇
 
Upvote 0
In your image there is no data in the cells of row 5, but in the formula that you put, you refer to cells of row 5 :unsure:

----- --


I did other tests for the dark blue, try:
Excel Formula:
=OR(AND($E6<>"",G$4>=$D6,G$4<=$E6),AND($E6<>"",$D6>=G$4,$D6<H$4))

----- --

Try:
Excel Formula:
=AND(TODAY()>=G$4,TODAY()<H$4)

😇
Thank you so much for the help. It is now working well.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,140
Members
449,098
Latest member
Doanvanhieu

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