HR and payroll checks: practice exercises
Who's missing from payroll, leavers still paid, salary mismatches to the penny, big pay changes, an exceptions count. 5 exercises on real-looking data, each checked as you go. The full lesson is part of Pro.
This lesson's exercises use a workbook with several sheets, so they open in the lesson rather than here.
How it works
Before a payroll run, many HR teams check their list of staff against the payroll export. Match people on their employee number, as names can be spelt differently in the two systems. COUNTIF(Payroll!A:A,A2) counts how often A2's number is on the Payroll sheet, so 0 means they're missing. XLOOKUP brings a figure across, such as their monthly pay, to compare.
Here monthly basic pay is the annual salary ÷ 12, rounded to the penny. Check how your own payroll does it. This lesson is about making the two lists agree. It doesn't work out tax or National Insurance.
=IF(COUNTIF(Payroll!A:A,A2)>0,"On payroll","Missing") =IF(AND(C2<>"",C2<$H$1,COUNTIF(Payroll!A:A,A2)>0),"Check","") =IF(ROUND(C2/12,2)<>XLOOKUP(A2,Payroll!A:A,Payroll!C:C),"Check","") =IF(ABS(D2-C2)/C2>$H$1,"Flag","") =COUNTIF(Checks!C:C,"Salary mismatch")
Two lists that should agree
The HR system says who works for you. The payroll export says who's about to be paid. Before the payroll run, check they agree: everyone employed is on payroll, nobody who's left is, and everyone is paid the right salary.
Match on the employee number. On another sheet, COUNTIF(Payroll!A:A,A2) counts how many times A2's number is in column A of the Payroll sheet: 0 means they're missing, and 2 means they're on it twice.
Worked example
For this example both lists are on one sheet: the HR list in A to C, payroll in F and G.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Number | Name | Salary (£) | On payroll? | Check | Payroll no. | Monthly pay |
| 2 | E20417 | Amira Khan | 27450 | E31865 | £2,087.50 | ||
| 3 | E31865 | Ben Clarke | 25050 | E40522 | £2,508.33 | ||
| 4 | E40522 | Cara Patel | 30100 | E20417 | £2,287.50 | ||
| 5 | E61734 | Ewa Nowak | 28600 | E61734 | £2,333.33 | ||
| 6 | E52290 | Dev Shah | 23800 |
=IF(COUNTIF($F$2:$F$5,A2)>0,"Yes","No")in D2. Dev started this month and hasn't been set up on payroll yet: No. Everyone else is there, in a different order.=IF(ROUND(C2/12,2)<>XLOOKUP(A2,$F$2:$F$5,$G$2:$G$5),"Mismatch","")in E2. Cara's £30,100 ÷ 12 is £2,508.333…, and payroll pays £2,508.33. ROUND makes them match. Ewa's £28,600 ÷ 12 is £2,383.33, but payroll still has £2,333.33 from her old salary: Mismatch.
Leavers still being paid
Leavers are paid up to their leave date. If November's pay period starts on 1 November, someone who leaves on 14 November gets a final payment in November, which is right. Someone who left on 31 October shouldn't be on November's payroll at all.
So flag anyone with a leave date before the start of the period who is still on the Payroll sheet. Watch out for blank leave dates: Excel treats an empty cell as 0 in a comparison, and 0 is before any date. Check the cell isn't blank first: =IF(AND(C2<>"",C2<$H$1,COUNTIF(Payroll!A:A,A2)>0),"Still paid","").
Pay that jumps
Sam was paid £2,150 in October and £2,580 in November. That's £430 more, and 430 ÷ 2,150 = 20%. In a formula the change is (D2-C2)/C2: the difference over last month's pay.
A drop matters too. If Sam had been paid £1,720, the change would be −20%. ABS drops the minus sign, so one test catches both: =IF(ABS(D2-C2)/C2>$H$1,"Check","") with the % limit in H1.
When the checks are done, the payroll manager wants the totals. If every exception is written in column C of a Checks sheet, =COUNTIF(Checks!C:C,"Salary mismatch") counts one kind.
What you'll practise
- The HR sheet lists everyone employed. The Payroll sheet is this month's payroll export, in a different order. In D2, show Yes if the person's employee number is on the Payroll sheet and No if it isn't. Your formula will be copied down to D19.
- Leavers are paid up to their leave date, so someone who left before this pay period started (the date in H1) shouldn't be on the Payroll sheet. In D2, show Still paid for anyone with a leave date before H1 who is still on the Payroll sheet. Leave it blank for everyone else, including staff with no leave date.
- Monthly basic pay should be the annual salary ÷ 12, rounded to the penny. In D2, look up each person's monthly basic pay on the Payroll sheet and show Mismatch if it isn't their salary ÷ 12 to the penny. Leave the cell blank if it matches.
- The payroll manager wants to look at anyone whose gross pay went up or down by more than the % in H1 since last month. In E2, show Check for them and leave the cell blank for everyone else. A change of exactly H1 doesn't need checking.
- The Checks sheet has one row per employee, with any exception found in column C. On this Summary sheet, in B2, count how many of the exception in A2 there are, for the payroll manager. Your formula will be copied down to B5.
Guides with worked examples: Compare two lists in Excel · XLOOKUP: a simple worked example