Underline the last of each cell with conditional formatting

DarkoDeign2

Board Regular
Joined
Jun 20, 2023
Messages
76
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a column $AI2:$AI1500 in this column I have ISO-week numbers (e.g. wk22)
In the next column $AJ2:$AJ1500 I have days of the week (e.g. Monday... Sunday). It can be multiple rows with the same days.

I want to a conditional format the last Sunday in every week in column AI.
What suggestions do you have for such a formula?
1689351291738.png
 

Attachments

  • 1689351181610.png
    1689351181610.png
    7.4 KB · Views: 7

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this:

Dante Amor
AIAJ
1Week noDays
228Friday
328Friday
428Saturday
528Saturday
629Sunday
729Sunday
829Sunday
929Monday
1029Monday
1129Tuesday
1229Tuesday
1329Friday
1429Saturday
1529Saturday
1630Sunday
1730Sunday
1830Sunday
1930Monday
2030Monday
2130Monday
2230Thursday
2330Friday
2430Saturday
2531Sunday
2631Sunday
2731Sunday
2831Monday
2931Tuesday
3031Wednesday
31
Hoja1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AJ1:AJ10000Expression=(AJ1="Sunday")*(COUNTIFS(AI2:AI$10000,AI1,AJ2:AJ$10000,AJ1)=0)textNO


In my example I am starting the conditional formatting in row 1, in cell AJ1, and the COUNTIFS function starts in the next row AI2 and AJ2.

=(AJ1="Sunday")*(COUNTIFS(AI2:AI$9987,AI1,AJ2:AJ$9987,AJ1)=0)

If you are going to change the numbering then you should consider it.
Also applies to starts in cell AJ1.
I gave the limit of 10000 as an example, but you can adjust it to the maximum number of rows that you are going to use.

Note: I put the conditional formatting with highlight in yellow, just to make it more noticeable, but you can change it to underline


--------------
Let me know the result and I'll get back to you as soon as I can.
Cordially
Dante Amor
--------------​
 
Last edited:
Upvote 0
Hi,

I don't know why but somehow this is not working for me. All I did was to replace the commas with semi-colons.
Instead of Sunday, Monday is highlighted...

1689415748370.png
 
Upvote 0
I don't know why but somehow this is not working for me. All I did was to replace the commas with semi-colons.
Instead of Sunday, Monday is highlighted...
Then most likely you (understandably) had row 2 as the active cell row when you applied the CF.

Here is another one you could try. It expects that you would have AI2 as the Active Cell when applying the CF

23 07 15.xlsm
AIAJ
1Week noDays
228Friday
328Friday
428Saturday
528Saturday
629Sunday
729Sunday
829Sunday
929Monday
1029Monday
1129Tuesday
1229Tuesday
1329Friday
1429Saturday
1529Saturday
1630Sunday
1730Sunday
1830Sunday
1930Monday
2030Monday
2130Monday
2230Thursday
2330Friday
2430Saturday
2531Sunday
2631Sunday
2731Sunday
2831Monday
2931Tuesday
3031Wednesday
CF Last
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AI2:AJ30Expression=AND($AJ2="Sunday",$AJ3<>"Sunday")textNO


If it is possible that you could have 2 adjacent rows with Sunday but from different weeks (as in rows 7 & 8 below) then you would need a further check in the formula.

23 07 15.xlsm
AIAJ
1Week noDays
228Friday
328Friday
428Saturday
528Saturday
629Sunday
729Sunday
830Sunday
930Sunday
1030Tuesday
1130Wednesday
1230Thursday
1330Friday
1430Saturday
1531Sunday
1631Monday
CF Last (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AI2:AJ16Expression=AND($AJ2="Sunday",$AI3&$AJ3<>$AI2&$AJ2)textNO
 
Upvote 0
Hi,

Thank you for the suggestion.
What do you mean with
"if it is possible that you could have 2 adjacent rows with Sunday but from different weeks (as in rows 7 & 8 below) then you would need a further check in the formula."?
Do you mean that I should use the latter formula or do you mean that I need to use both formulas?
 
Upvote 0
Do you mean that I should use the latter formula
That is what I mean.

You can see in my second mini sheet that I have just used one formula and that sheet still highlights the last Sundays of weeks 29, 30 and 31 which I think is what you want?

If the formula from my first mini sheet is used with the data from the second mini sheet then the last Sunday of week 29 would get missed - see below

23 07 15.xlsm
AHAIAJ
1Week noDays
228Friday
328Friday
428Saturday
528Saturday
629Sunday
7This row is missed -->29Sunday
830Sunday
930Sunday
1030Tuesday
1130Wednesday
1230Thursday
1330Friday
1430Saturday
1531Sunday
1631Monday
CF Last (3)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AI2:AJ16Expression=AND($AJ2="Sunday",$AJ3<>"Sunday")textNO
 
Upvote 1
You're welcome. Glad we were able to help. Thanks for the follow-up. :)
 
Upvote 0
As the next step I was thinking column "AT". To have a formula that adds the numbers in column "AR" that correlates to the same week.
Here is my formula but it is not working.. It is something wrong with the "SUMIF".
=IF(AND($AL2="Sunday";$AK3&$AL3<>$AK2&$AL2);SUMIF($AK$2:$AK$1500;$AK2;$AR$2:$AR$1500))

1689845817751.png
 
Upvote 0
Looks pretty close. It appears to just be missing what to return on all the other rows. Of course mine has commas where your will apparently have semicolons.

DarkoDeign2.xlsm
AKALARAT
1Week noDays
2wk28Friday1 
3wk28Friday2 
4wk28Saturday3 
5wk28Saturday4 
6wk29Sunday5 
7wk29Sunday6 
8wk29Sunday795
9wk29Monday8 
10wk29Monday9 
11wk29Tuesday10 
12wk29Tuesday11 
13wk29Friday12 
14wk29Saturday13 
15wk29Saturday14 
16wk30Sunday15 
17wk30Sunday16 
18wk30Sunday17171
19wk30Monday18 
20wk30Monday19 
21wk30Monday20 
22wk30Thursday21 
23wk30Friday22 
24wk30Saturday23 
25wk31Sunday24 
26wk31Sunday25 
27wk31Sunday26159
28wk31Monday27 
29wk31Tuesday28 
30wk31Wednesday29 
CF Last
Cell Formulas
RangeFormula
AT2:AT30AT2=IF(AND($AL2="Sunday",$AK3&$AL3<>$AK2&$AL2),SUMIF($AK$2:$AK$1500,$AK2,$AR$2:$AR$1500),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AK2:AL30Expression=AND($AL2="Sunday",$AL3<>"Sunday")textNO
 
Upvote 0

Forum statistics

Threads
1,215,143
Messages
6,123,280
Members
449,094
Latest member
GoToLeep

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