Reading time: about 10 minutes
This is the first case of the block and deliberately the easiest of the four: automating starts here, not with an agent. A spreadsheet that turns red for anything expiring within 90 days never crashes, costs nothing, sends nothing anywhere and solves the whole problem. Before automating something complicated, it helps to have automated something that works.
Step by step
-
Decide the columns before typing any
Five, and no more: product, batch, expires, units, where it is. The last one is the one almost nobody adds and the one that makes the sheet useful: knowing something expires is no good if it takes twenty minutes to find.
Dates are always written the same way —
31/01/2027— down the whole column. A date written as text ("Jan 27") cannot be calculated by any formula, and it is the number one reason these sheets do not work.Check the sheet understood them as dates: if they align to the right on their own, they are dates. If they stay left, they are text and the column format needs fixing before you go on.
-
Ask for the formulas and for an explanation
The important part of the prompt is not the formulas: it is "explain what each one does". A sheet with formulas you do not understand breaks the day you add a column and you will not know how to fix it. This case is not about having a sheet: it is about having a sheet that is yours.
I have a spreadsheet in Google Sheets to control expiry dates in a pharmacy. Columns: A: Product B: Batch C: Expires (date, dd/mm/yyyy) D: Units E: Where it is Give me, to paste into row 2 and drag down: 1. In F: the DAYS remaining until expiry. 2. In G: a text status: "EXPIRED", "URGENT" (under 30 days), "CHECK" (under 90) or "OK". 3. The conditional formatting so the whole row colours: red if expired, orange if urgent, yellow if it needs checking. 4. A cell at the top telling me how many products are in each status. FOR EACH FORMULA, explain in two lines WHAT IT DOES, as if I knew nothing about spreadsheets. I want to be able to change the 30 and the 90 myself without breaking it. Tell me as well what happens if a date cell is empty, because it will happen. -
Test it with three dates whose answer you know
This is the check of this case and it is the same idea as testing an agent before letting it loose: you feed it cases whose answer you know and see if it gets them right.
A date from last year: must come out EXPIRED. One two weeks away: URGENT. One two years away: OK. And a fourth, the one that matters: leave a date cell empty and see what it does. If it paints the row red, you have a sheet that will shout at you for every half-filled line and you will stop looking at it within a week.
If something is wrong, do not rewrite the formula by eye: say "with an empty cell I get EXPIRED and it should stay blank". It fixes it and explains why it happened.
-
Add the automatic alert, which is what makes it automatic
A sheet you have to remember to open is not automated: it depends on you. The step that changes that is the sheet alerting you.
In Google Sheets this is a small script that runs on its own once a week and emails you what is red. You do not need to know how to write it: you ask.
And there is one instruction that cannot be left out of that prompt: the script only READS the sheet and never writes to it. It is the same rule as the read-only agent two cases further on, and this is where you practise it for the first time.
Write me a Google Apps Script for this sheet. WHAT IT MUST DO: - Run Mondays at 8 in the morning. - Read the sheet and keep the rows whose status (column G) is "EXPIRED" or "URGENT". - Email me at my address with that list: product, batch, days remaining and where it is. - If there are none, send NO email at all. RULES: - The script ONLY READS the sheet. It does not write, delete or modify ANYTHING. - It emails nobody but me. - If something fails, say so in the email rather than failing silently. Explain step by step where this is pasted and how to schedule it to run on its own, as if I had never done it. And tell me what permissions Google will ask for and why.
Note the "if there are none, send no email" instruction. It is the same lesson as this site’s own BOE cron: a weekly email saying "0 products" trains you to ignore the alert, and then the day it arrives with fifteen nobody looks at it.
-
What this sheet does NOT replace
It replaces the notebook and one person’s memory. It does not replace your pharmacy software’s expiry control if you have one, nor physically checking the shelf, nor any records you are required to keep.
It is a support, and as such it has a specific weakness worth remembering: it only knows what somebody entered. A product nobody wrote down does not expire in the sheet, and a sheet that has been green for two months may mean nothing is expiring or that nobody is entering anything. Those are opposites and they look identical.
Which is why it is worth recording somewhere the date something was last added. It is one more column and it tells you which of the two you are looking at.
A full example, and what is wrong with it
The step 2 sheet with step 3’s four test dates in: one from last year, one two weeks away, one two years away, and an empty cell.
Row 2 — expires 15/03/2026 → F2 = -185 → G2 = EXPIRED ✔
Row 3 — expires 30/09/2026 → F3 = 14 → G3 = URGENT ✔
Row 4 — expires 01/10/2028 → F4 = 745 → G4 = OK ✔
Row 5 — C5 EMPTY → F5 = -46281 → G5 = EXPIRED ✘
And the cell above counts: "EXPIRED: 2 · URGENT: 1 · CHECK: 0 · OK: 1".
And now, what is wrong with that reply:
- Three of four are right, and the fourth is the one that matters. The empty cell gives
-46281because Excel reads it as day zero of its calendar, 1 January 1900. The number is absurd and the label is believable: the row turns red and is indistinguishable from a genuinely expired one. On a twenty-line sheet you notice; on a two-hundred-line one, you do not. - The counter above says 2 EXPIRED and that propagates. That is the failure leaving the row and entering the summary. Add the step 4 automatic alert and Monday’s email will tell you there are two expired products and one of them does not exist. Two Mondays like that and you stop opening the email — which is exactly how an automation dies.
- The negative days are correct and useful.
-185is not an error: it is how many days it has been expired, and sorting by that column puts what has been sitting longest at the top. It is a side effect you did not ask for and worth knowing about — not everything that looks odd is wrong. - And it gives you the fix the moment you mention it. Write "with an empty date cell I get EXPIRED and it should stay blank" and it returns the formula with an emptiness check in front, apologising. The good formula existed all along; the only thing missing was testing the case — which is this whole lesson.
Four test rows, two minutes, and it catches the one failure that would have got the sheet abandoned within a week. None of the other three would have taught you anything.
And that is why the ugly case goes in deliberately rather than waiting for it to turn up: when it turns up on its own it will be on a two-hundred-line sheet and you will not know why the counter is off.