AI Agents and Coding Assistants

Spreadsheet Formulas and Small Scripts: Safe First Projects With AI

Beginner projects where you can check AI's work yourself, with worked formula examples, a safe script routine and common traps.

Key takeaways

  • Choose tasks where you already know what a correct answer looks like.
  • Describe your columns, give sample rows and state what should happen with blanks and errors.
  • Check results by hand on a few rows, including awkward ones, before trusting the whole sheet.
  • Run scripts only on copies, preview changes first and never run code you cannot get explained.
  • Keep private and employer data out of public tools unless you are allowed to share it.

The best first projects for building things with AI are small, private and easy to check: a spreadsheet formula whose answer you can verify by hand, or a short script that works on copies of files. If something goes wrong, you lose a few minutes and nothing else.

A formula is an instruction in a spreadsheet cell that calculates a value from other cells. A script is a short program, often a single file, that carries out a task when you run it. An AI assistant can draft either from a plain description, and can explain each part if you ask.

Why start small

A good beginner project has four features. You can tell whether the result is right. Mistakes can be undone. No one else depends on it yet. It contains no sensitive information, or you can substitute invented data.

Payroll, tax filings, medication schedules and anything that sends messages to real people fail that test. Start with a reading log, a household budget using made-up figures, a list of club events or a folder of copied photos.

A first formula, checked by hand

Suppose, as an example, column A holds item names, column B quantities and column C unit prices, with data in rows 2 to 4. You ask: "Write a formula for column D that multiplies quantity by price and leaves the cell blank if either is missing." A typical answer, in common spreadsheet syntax, for cell D2:

=IF(OR(B2="", C2=""), "", B2*C2)

Read it from the inside out. OR is true if either cell is empty. IF then returns empty text in that case, and otherwise the product. Copied down, the row numbers adjust to 3 and 4.

Now test it with values you can compute yourself.

Row Quantity Unit price Expected in D
2 3 4.50 13.50
3 0 8.00 0
4 (blank) 2.00 blank

Row 3 matters. A quantity of zero is a real value and should give 0, not a blank. A formula that treated zero as missing would pass row 2 and fail here. Function names and separators differ between spreadsheet programs and regional settings, so say which one you use.

Totals, ranges and silent errors

The total might be =SUM(D2:D4), which for the example gives 13.50 + 0 = 13.50, since the blank result is ignored.

The classic trap is a range that stops short. If you later add row 5 outside the range, the total may not include it, and nothing warns you. Another is a reference that shifts when copied. A tax rate stored in cell F1 should usually be written as $F$1, which keeps it fixed; plain F1 would become F2, F3 and so on down the column.

Numbers stored as text are a third. They look fine but are skipped by SUM. Ask the assistant how to detect them, and compare your total with a rough mental estimate. Trusting AI with arithmetic explains why a formula that computes is safer than asking a chatbot for the sum.

A second formula: counting with a condition

Say a reading log lists book titles in column A and a status in column B, with five entries in rows 2 to 6: done, reading, done, planned, done. To count finished books, an assistant would likely suggest:

=COUNTIF(B2:B6, "done")

Counting by eye, "done" appears three times, so the answer should be 3. To get the share finished, divide by the number of titles:

=COUNTIF(B2:B6, "done") / COUNTA(A2:A6)

COUNTA counts cells that are not empty. Here it gives 5, so the result is 3 ÷ 5 = 0.6, or 60 percent once the cell is formatted as a percentage.

Now probe the edges. What if someone types "Done " with a trailing space? Capital letters are usually ignored by this kind of count, but the extra space will generally prevent a match. What if the list is empty? COUNTA returns 0 and the division produces an error, which you can handle with an IF test on the count.

A drop-down list of allowed status values prevents most typing variations. That is a common lesson from small projects: tidy input saves you from clever formulas.

How to ask well

Include the facts the assistant cannot see:

  1. The program or language you are using.
  2. What each column or input contains, with two or three invented sample rows.
  3. The exact result you want for those rows.
  4. What should happen with blanks, duplicates, text in number fields and zero.
  5. A request to explain each part in plain words.

If the answer is a long, tangled formula, ask for helper columns, one step in each. They are easier to check and repair. AI for spreadsheet analysis goes further once the basics work.

A first script, done safely

Say you want to add the year to the front of file names in a folder of scanned recipes. This is a good script project if you follow a careful routine.

A safe routine for a first script
1 Copy Work on a duplicate folder, keep the original 2 Describe State the change and what to skip 3 Explain Have the assistant walk through each part 4 Preview Print the planned changes without making them 5 Run small Try a few files, then check them 6 Run all Apply to the copy and compare counts Copy Work on a duplicate folder, keep the original 1 Describe State the change and what to skip 2 Explain Have the assistant walk through each part 3 Preview Print the planned changes without making them 4 Run small Try a few files, then check them 5 Run all Apply to the copy and compare counts 6

Ask for a preview mode, often called a dry run, in which the script lists "old name → new name" and changes nothing. Ask it to refuse to overwrite an existing file and to skip names that already start with the year, so that running it twice does no harm.

Read the list. Are there files you did not expect? Do any two end up with the same name? Only then switch preview off. Afterward, confirm that the number of files matches the number you started with.

When something goes wrong

Errors are normal and informative. Spreadsheet error codes usually point at a type of problem, such as a division by zero, a missing reference or text where a number was expected. Scripts print messages that often name the line that failed.

Copy the message exactly, say what you expected and give the smallest example that shows it. A clear bug description gets better help than "it does not work."

Change one thing at a time. If a suggested fix fails, undo it before trying the next, so that you are not stacking guesses. For scripts, restore the folder from your original copy before each new run, which gives every attempt the same starting point.

Watch for fixes that hide problems. Wrapping a formula so that every error shows as a blank makes the sheet look clean while rows drop out of your totals. Prefer a visible message such as "check this row," and handle only the cases you understand.

What not to run

Be wary of any script that deletes files, asks for administrator rights, downloads and runs something else, changes system settings or asks for passwords, unless you understand why and trust the source. None of these should be needed to rename copies of recipes.

Do not paste code from a stranger into your computer's command window because a message told you to. Get your assistant's explanation, but remember that explanations can be wrong. On a work computer, follow your organization's rules about running scripts. Spreadsheet macros (recorded or written programs inside a document) can be harmful too, so keep protections on and do not enable macros in files from unknown sources.

Protect your data

A spreadsheet often holds names, addresses, salaries or health notes. Before asking for help, replace real rows with invented ones that have the same shape. The assistant needs the structure, not the people. See what to keep out of a public chatbot.

Assistants built into spreadsheet programs may read the whole file. Check the settings and your employer's policy before turning one on for sensitive work.

Keep what you learn

Add a notes tab or a short text file saying what each formula or script does, an example of correct output and the date. In six months, you will be glad.

Then stretch a little. Add a check cell that flags a total that does not match. Change the script to handle a new case, predicting the result before running it. Ask why a formula works instead of only asking for a new one.

When a project outgrows this

Signs that you have moved past a small project include other people relying on the results, money or safety depending on them, a script running on a schedule with nobody watching, or a spreadsheet only one person dares to edit. At that point, ask for a review from someone experienced, add tests or cross-checks and write down how to do the job by hand. If the idea grows into something others sign in to, read about where building by description breaks before going further.

Written for 4ArtificialIntelligence with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 46 articles in AI Agents and Coding Assistants →

Latest news on this topic