Excel formulas written by AI keep erroring as soon as you paste them in, and in most cases the AI did not calculate wrong. Your Excel version, your language environment and the data formats inside your sheet simply do not match the setup it assumed. Before asking it to rewrite everything, work through the four points below one by one; you can usually locate the problem yourself.
Point one: function names and separators do not match your environment
By default AI writes for the English edition of Microsoft Excel, with English function names and commas between arguments. Open the same formula in a Chinese or another localized edition and it may need localized function names and semicolons instead, and WPS, Microsoft Excel and Google Sheets do not behave identically either. If pasting immediately triggers #NAME?, check this point first and adapt the names and separators to the app you actually use.
Point two: the function does not exist in your version at all
XLOOKUP, TEXTJOIN and dynamic array functions only arrived in newer versions; older Excel releases simply do not have them. The AI does not know which version you run, so it reaches for the newest functions. State your version number when you ask, and require an older-version alternative at the same time, for example INDEX plus MATCH instead of XLOOKUP, so the formula does not fail on a missing function.
Point three: your data is not the type it assumes
The logic can look flawless while the result is #VALUE! or zero, and the fault often sits in the data itself: numbers stored as text, dates that only look like dates, stray spaces inside cells, and merged cells getting in the way. Stop staring at the formula alone. Pull out a few rows of real data, check their formats, strip extra spaces, unmerge what does not need merging, and calculate again.
Point four: the request was underspecified, so it had to guess
If you never said whether the sheet has a header row, whether blanks should stay blank or count as zero, or which rows and columns must stay locked when the formula is filled down, the AI can only guess. The classic case is a missing $ absolute reference: after dragging, the references drift, the first rows look right and everything below shifts out of place. Next time, state these points up front: header or not, how to treat blanks, and which rows or columns to lock.
Troubleshoot in this order
Start with the error code: #NAME? points to function names and language, #VALUE! to data types, #REF! to a reference range that was deleted or exceeded, and #N/A usually means the lookup found no match. Then send the AI your app name, version, interface language and five rows of sample data together, and ask it to explain what each function does, piece by piece, plus provide an older-version compatible version. Finally, never edit the live sheet directly: copy it first, test on a small range, and only roll the formula out once the test matches.
Keep a human check on anything involving money
For sheets tied to amounts, expenses or reported figures, never trust an AI formula unchecked; hand-calculate a few sampled rows and compare. When a complex array formula goes wrong, have it split into several helper columns that compute step by step. Each step can be verified on its own, which is far faster and safer than guessing where one long formula broke.