LibreOffice Calc · Formula troubleshooting · Intermediate
Fix LibreOffice Calc Err:502 (Invalid Argument)
Understand LibreOffice Calc Err:502 and fix invalid function arguments, including mismatched COUNTIFS range sizes with tested examples.
Updated 10 October 2026 · Formula checks: testing standards
Err:502 in LibreOffice Calc means Invalid argument. A function received an input that does not meet its requirements. It does not mean the entire document is damaged, and it is different from a missing operator or bracket.
Common example: mismatched COUNTIFS ranges
Suppose category names are in A2:A6 and amounts are in B2:B6. This malformed formula compares ranges with different numbers of rows:
=COUNTIFS(A2:A6;"A";B2:B5;">0")
The first criterion range has five cells and the second has four. Expected error: Err:502 in LibreOffice Calc. Fix the ranges so they have matching dimensions:
=COUNTIFS(A2:A6;"A";B2:B6;">0")
Now Calc can test both criteria for each corresponding row.
Five troubleshooting steps
- Select the error cell and inspect the complete formula in the formula bar.
- Identify the function reporting the problem. Test nested functions separately in empty cells if the expression is complex.
- Check argument types, such as number versus text, and the allowed value range documented for that function.
- For multi-range functions such as COUNTIFS and SUMIFS, confirm matching row and column counts.
- Rebuild the expression one criterion at a time to find the exact bad argument.
Do not confuse similar errors
| Code | General meaning | Typical first check |
|---|---|---|
| Err:502 | Invalid argument | Argument value, type or range dimensions |
| Err:509 | Missing operator | Missing *, + or another operator |
| Err:508 | Bracketing problem | Unmatched parentheses |
See the Err:509 walkthrough if the problem is a missing multiplication symbol.
Avoid hiding the original issue
IFERROR(formula;"-") can hide an error from a report, but it does not repair invalid inputs. Correct the argument first; use error-handling functions only when the remaining error is a legitimate possible outcome.
Common questions
Does Err:502 always mean mismatched ranges? No. That is only one clear, reproducible cause. Any invalid function argument may produce the code.
Why does the same function work with simpler data? One argument may have an unsupported type or value. Isolate the inputs and compare them with the function’s official syntax.
Official reference: LibreOffice Help. This tutorial focuses on LibreOffice Calc; menu names and behavior can vary by version, operating system and locale.