Conditional Formatting - Formula and VBA Solution

D_Ireri

New Member
Joined
Jan 9, 2014
Messages
4
Hi

I have a vacation summary for various employees as show on the extract below. I would like a conditional format that highlights the dates taken by staff who are in a similar department and who have applied for vacation in the same month on the same dates. For instance, Staff A and Staff C are both in Department A and have both applied for vacation in the month of January on the same dates. The conditional formatting would then be applied to dates 7, 8 and 9 for both Staff A and Staff C.

On my spreadsheet, the data starts on row A1 and I am using Excel 2013. Please assist me with both a formula and a VBA solution.


MonthStaff NameDepartmentDates TakenDates TakenDates TakenDates TakenDates TakenDates TakenDates TakenDates TakenTotal Days Taken
JanuaryStaff ADepartment A12347897
JanuaryStaff BDepartment B127891011128
JanuaryStaff CDepartment A7893
FebruaryStaff DDepartment A482
FebruaryStaff EDepartment B6783
MarchStaff FDepartment A141
MayStaff ADepartment A71
JuneStaff FDepartment D891011125
JulyStaff BDepartment B4569105

<tbody>
</tbody>

Thanks

David
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

This will count the occurrences of a date given the month and the department (minus 1):
(Apply with Control+Shift+Enter)
Code:
IF(ISBLANK(D2),0,SUM(IF($A2=$A$2:$A$11,IF($B2=$B$2:$B$11,IF(D2=$D$2:$K$11,1,0),0),0))-1)

I don't know if you can use an array formula with conditional formatting but you could apply the formula to the right of your data and then use conditional formatting.

Hope it helps
 
Upvote 0
I used the staff instead of the department. The formula should be
Code:
[COLOR=#333333]IF(ISBLANK(D2),0,SUM(IF($A2=$A$2:$A$11,IF($C2=$C$2:$C$11,IF(D2=$D$2:$K$11,1,0),0),0))-1)[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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