Case 6: Weekly summary at the push of a button with VBA
Every Monday the team lead wants to know what is open, who has how much on their plate and what is due in the coming days. So far someone counts by hand and types the numbers in. Three macros take over: counts per status, counts per owner and a print-ready week sheet.
In short: WorksheetFunction.CountIf(statusRange, "open") counts one status, and CountIfs counts with two conditions, such as owner and status. A Dictionary collects the names without duplicates. Values you transfer with .Value arrive without their format, so the macro sets the date format itself, as d mmm yyyy, which reads the same in the US and the UK.
The situation
The team keeps its tasks in a list with the columns Task, Owner, Due and Status. The status is one of three values: "open", "in progress", "done". Three people share the work, and now and then someone new joins. In the exercise it is Monday, 16 Mar 2026 again.
Task 1: counts per status
Task Every Monday the team lead wants to know how many tasks are open, in progress and done. Write a macro WeeklySummary that adds a new sheet "Summary" after the last one. On it, A1 says "Weekly summary as of " followed by today's date in the form 16 Mar 2026, A3:B3 hold "Status" and "Count", A4 to A6 hold "open", "in progress" and "done" with the matching count in B, and A7 holds "Total" with the number of all tasks in B7. A1, A3:B3 and A7:B7 are bold.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Task | Owner | Due | Status |
| 2 | Send team meeting minutes | Patel | 16 Mar 2026 | open |
| 3 | Book training room | Brooks | 17 Mar 2026 | done |
| 4 | Order office supplies | Okafor | 18 Mar 2026 | in progress |
| 5 | Check expense claims | Patel | 13 Mar 2026 | open |
| 6 | Set up desk for new starter | Brooks | 19 Mar 2026 | in progress |
| 7 | Update phone list | Okafor | 20 Mar 2026 | open |
| 8 | Post time-critical mail | Patel | 16 Mar 2026 | done |
| 9 | Confirm printer service | Brooks | 23 Mar 2026 | open |
| 10 | Archive February files | Okafor | 11 Mar 2026 | done |
| 11 | Collect leave requests | Patel | 22 Mar 2026 | in progress |
CountIf is Excel's COUNTIF, called through WorksheetFunction. Set the range once as a variable, down to the last row, and new tasks are counted automatically. If you forget to name the new sheet, it keeps the name Excel gives it, and the exercise reports: "The sheets are not right. Expected: Tasks, Summary. Yours: Tasks, Sheet2."
The title uses the date rather than a week number on purpose. US calendars often count weeks from the week containing 1 January, starting on Sunday, while ISO week numbers, common in Europe, start on Monday; the same day can have different week numbers. "As of 16 Mar 2026" means the same everywhere.
Task 2: counts per owner
Task Now the summary should also show who has how much on their plate. Row 1 of the Summary sheet already holds the headers. Write a macro CountByOwner that writes one row per owner from row 2 down: the name in A, the number of their tasks with the status from the header above in B to D, and the total in E. Owners appear in the order in which they first show up in the task list. Collect the names with a Dictionary, so nobody appears twice and new colleagues are added automatically.
Tasks
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Task | Owner | Due | Status |
| 2 | Send team meeting minutes | Patel | 16 Mar 2026 | open |
| 3 | Book training room | Brooks | 17 Mar 2026 | done |
| 4 | Order office supplies | Okafor | 18 Mar 2026 | in progress |
| 5 | Check expense claims | Patel | 13 Mar 2026 | open |
| 6 | Set up desk for new starter | Brooks | 19 Mar 2026 | in progress |
| 7 | Update phone list | Okafor | 20 Mar 2026 | open |
| 8 | Post time-critical mail | Patel | 16 Mar 2026 | done |
| 9 | Confirm printer service | Brooks | 23 Mar 2026 | open |
| 10 | Archive February files | Okafor | 11 Mar 2026 | done |
| 11 | Collect leave requests | Patel | 22 Mar 2026 | in progress |
Summary
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Owner | open | in progress | done | Total |
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 |
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
Here the Dictionary is just a list without duplicates. Because it keeps the keys in the order they were added, the owners appear in the summary in the order they first show up in the task list. The macro takes the statuses from the header of the Summary sheet; that saves three nearly identical lines and turns a fourth status into a matter of one more header. With CountIf instead of CountIfs, the macro would count each status across all owners, and the first counter would already be too high.
Task 3: the week sheet
Finally, the sheet that gets printed and pinned up by the phone: every task that is not done and is due within the next seven days, overdue ones included. The window is the same as in case 3.
Task Finally, the sheet that gets printed every Monday and pinned up by the phone. Write a macro AddWeekSheet that adds a new sheet "Week of 16 Mar" after the last one (today's date in the form d mmm). A1:D1 hold "Task", "Owner", "Due", "Status", in bold with a grey fill of RGB(217, 217, 217). Below that, every task that is not done and is due within the next 7 days (up to and including Date + 6), the overdue ones included, with all four columns. The list is sorted by due date, earliest first, and column C shows the date in the format "d mmm yyyy".
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Task | Owner | Due | Status |
| 2 | Send team meeting minutes | Patel | 16 Mar 2026 | open |
| 3 | Book training room | Brooks | 17 Mar 2026 | done |
| 4 | Order office supplies | Okafor | 18 Mar 2026 | in progress |
| 5 | Check expense claims | Patel | 13 Mar 2026 | open |
| 6 | Set up desk for new starter | Brooks | 19 Mar 2026 | in progress |
| 7 | Update phone list | Okafor | 20 Mar 2026 | open |
| 8 | Post time-critical mail | Patel | 16 Mar 2026 | done |
| 9 | Confirm printer service | Brooks | 23 Mar 2026 | open |
| 10 | Archive February files | Okafor | 11 Mar 2026 | done |
| 11 | Collect leave requests | Patel | 22 Mar 2026 | in progress |
This exercise is part of Premium.
Premium unlocks every exercise in every lesson, unlimited practice with fresh tasks and the final test with certificate.
See Premium Already Premium? Log in
The first exercise in this lesson is free.
The macro transfers values, not formats. Without a number format of its own, column C would show numbers like 46097, and the exercise reports: "The number format is not right in Week of 16 Mar!C2 (NumberFormat)." Sorting happens only on the new sheet; the task list stays the way the team keeps it.
Common mistakes
Statuses spelled differently
CountIf ignores upper and lower case, but not the difference between "in progress" and "in progress" with two spaces. If the counts don't add up to the number of tasks, that is almost always why. Data validation with a list on the status column prevents it from the start.
Running twice on the same day
If the macro from task 3 runs twice on the same day, it fails on the sheet name "Week of 16 Mar", which then already exists. Case 4 shows how to check first. Alternatively, the macro deletes the old week sheet first, with Application.DisplayAlerts = False before the Delete so that no prompt appears.
A range of fixed length
A fixed range such as Range("D2:D11") only counts today's ten tasks. The check also runs with a longer list and a new colleague; fixed limits show up there.
In real Excel
Put the three macros in one module and add a fourth that calls them in turn. Add a button to the Tasks sheet (Developer > Insert > Button) and assign that macro to it. Then the weekly summary really is one click. The create a report lesson shows how building blocks like these grow into a full report.
Check your result
- Task 1: "Weekly summary as of 16 Mar 2026", open 4, in progress 3, done 3, total 10.
- Task 2: Patel 2, 1, 1 with a total of 4; Brooks and Okafor 1, 1, 1 each with a total of 3.
- Task 3: a sheet "Week of 16 Mar" with six tasks, "Check expense claims" (13 Mar 2026) at the top and "Collect leave requests" (22 Mar 2026) at the bottom. The printer service on 23 Mar is not on it; that is next week's.
Course complete
With this case you have worked through all six cases of the intensive course. You have cleaned and matched lists, checked deadlines, added sheets, logged changes and built summaries: the routine that comes back every week in almost every office. Your progress and the certificate form are in the course view in your account.
Back to case 5 or to the course overview.