Formula Generator

Excel Formula Generator — StashGrid

Build formulas instantly for Excel, Google Sheets, or Google Docs — with explanations for every formula.

App:
Choose a formula
← Select a formula to get started

Quick reference

Formula fundamentals that prevent most spreadsheet bugs

Almost every broken spreadsheet traces back to one of a handful of misunderstandings. None of them are advanced, and all of them cost hours once a file has grown. This section covers the ones worth knowing before you build anything you intend to keep.

Absolute and relative references — the dollar signs

A reference like A1 is relative: copy the formula one row down and it becomes A2. That is usually what you want, and it is also the single most common cause of a formula that works in the first row and produces nonsense in the rest.

A dollar sign locks the part it precedes:

The classic case is a tax or commission rate sitting in one cell. Write =B2*$E$1 and you can fill the column safely; write =B2*E1 and row three multiplies by whatever happens to be in E2, which is often blank — giving you zeros rather than an error, which is far worse because nothing looks wrong. Pressing F4 while editing a reference cycles through the four states.

XLOOKUP, INDEX/MATCH, and why VLOOKUP keeps breaking

VLOOKUP has two design flaws that cause real damage. It can only look to the right of the lookup column, and it addresses the return column by position number rather than by name. Insert a column anywhere in the middle of the range and every VLOOKUP pointing past it silently returns the wrong field. No error, no warning — just wrong numbers in a report.

Two replacements avoid this:

If you must use VLOOKUP, always pass FALSE (or 0) as the fourth argument. Omitting it requests an approximate match against data that is assumed to be sorted, and on unsorted data that returns confidently wrong results rather than an error.

What each error actually means

Wrap a lookup in IFERROR to show something friendlier: =IFERROR(XLOOKUP(...), "Not found"). Use it deliberately, though — IFERROR hides every error, including the #REF! that would have told you the formula is broken. IFNA is the safer choice when you only want to catch failed lookups.

Numbers stored as text

This is the most common data problem in any imported spreadsheet. Values that look like numbers are actually text, so SUM quietly returns zero and lookups fail to match. The usual signs are left-aligned values (numbers align right by default) and a small green triangle in the cell corner.

Causes include leading apostrophes, non-breaking spaces from a web copy-paste, thousands separators, currency symbols, and CSV imports where the column was typed as text. Fixes range from multiplying by 1, to =VALUE(TRIM(A1)), to Text to Columns with the right format. TRIM removes ordinary spaces but not non-breaking ones — for those you need SUBSTITUTE(A1, CHAR(160), "") first.

Dates are numbers wearing a costume

A date is stored as a serial number counting days from a fixed origin, and the date you see is formatting applied on top. That is why subtracting two dates gives a plain number of days, and why a date occasionally appears as something like 45,292 — the value is fine, the format was lost.

It also means dates imported as text will not sort, filter or subtract correctly no matter how right they look. And be careful with regional order: 03/04/2026 is March 4th or April 3rd depending on locale, and a mixed import can silently convert only the rows where the interpretation is unambiguous.

Use the plural forms

SUMIFS, COUNTIFS and AVERAGEIFS accept multiple conditions, and their argument order is more logical than the singular versions — the range to sum comes first, followed by condition pairs. Prefer them even for a single condition, so adding a second criterion later does not mean rewriting the formula backwards.

Excel and Google Sheets are not quite the same

Habits that pay off later

Frequently asked questions

How do I use VLOOKUP in Excel?

VLOOKUP searches for a value in the first column of a range and returns a value from another column in the same row. Syntax: =VLOOKUP(lookup_value, table_array, col_index_num, FALSE). Always use FALSE for exact matches. Use INDEX MATCH instead if your table structure changes often.

What is the difference between VLOOKUP and INDEX MATCH?

INDEX MATCH can look left (VLOOKUP can't), doesn't break when you insert columns, and is faster on large datasets. Both work identically in Excel and Google Sheets. Use our builder above to generate both.

Do Excel formulas work in Google Sheets?

Most do — VLOOKUP, INDEX MATCH, IF, IFS, SUMIF, SUMIFS, COUNTIF, and text functions work identically. Google Sheets adds exclusive functions like QUERY, IMPORTRANGE, ARRAYFORMULA, SPLIT, and SPARKLINE that don't exist in Excel.

What is QUERY in Google Sheets?

QUERY lets you filter, sort, and aggregate data using SQL-like syntax directly in a cell. Example: =QUERY(A:C,"SELECT A, SUM(C) WHERE B='East' GROUP BY A"). It's one of the most powerful Sheets-exclusive functions.

What is XLOOKUP and when should I use it?

XLOOKUP is available in Excel 365, Excel 2021, and Google Sheets. It replaces VLOOKUP with no column number needed, works in any direction, and handles missing values with a built-in fallback parameter.

How do I fix a #N/A error in VLOOKUP?

#N/A means VLOOKUP can't find the value. Common causes: leading/trailing spaces (fix with TRIM), number stored as text, or the value doesn't exist. Wrap in IFERROR: =IFERROR(VLOOKUP(...),"Not found").

Copied!