Highlight Month Columns based on dates in Google Sheet

Viewed 359

I would highlight, in Google Sheet, the columns of months based on dates in col AA:
dd/mm/yyyy (start date) - dd/mm/yyyy (end date).

Example:
Col AA ---> 25/05/2022 - 06/09/2022
The columns that must be highlighted: from May to September.

2 Answers

The best way is to change headers of column and put inside the first day of each month. Then apply a format as MMMM.

Conditionnal formatting formula:

=and(C$1>=EOMONTH($A2;-1)+1;C$1<=EOMONTH($B2;0))

if you can't change headers, the formula will be:

=and(MATCH(proper(text(index(split($AA2;" - ");1);"MMMM"));{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0)<=MATCH(B$1;{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0);MATCH(proper(text(iferror(index(split($AA2;" - ");2);"31/12/2022"*1);"MMMM"));{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0)>=MATCH(B$1;{"Gennaio";"Febbraio";"Marzo";"Aprile";"Maggio";"Giugno";"Luglio";"Agosto";"Settembre";"Ottobre";"Novembre";"Dicembre"};0))

You can try a much simpler formula:

=(EOMONTH(DATEVALUE("1/"&C$1);0)>$A2)*(DATEVALUE("1/"&C$1)<=$B2)

this works for current year.

If you want to use another year add it to string in DATEVALUE function, i.e. =DATEVALUE("1/"&C$1&"/2020")

enter image description here

Related