Excel formulas with worked examples

Five formulas cover most of the spreadsheet work people actually get stuck on: counting rows that meet a condition, counting between two numbers, hiding errors behind a clean result, adding the same cell across many sheets, and converting a date from one layout to another. Each one below is written as you would type it, with a worked example.

COUNTIF and IFERROR #

COUNTIF counts how many cells meet one condition:

=COUNTIF(B2:B500, "North")

That counts rows where column B says North. The second argument also accepts wildcards and comparisons: ">100", "N*", or a cell reference if you want the condition in a cell.

IFERROR wraps anything that can fail and gives you a result instead of #N/A:

=IFERROR(VLOOKUP(A2, Products!A:C, 3, FALSE), "Not found")

Use it around lookups and divisions, not around everything. A sheet full of IFERROR hides real problems — a broken reference looks the same as a missing product.

Count cells between two numbers #

Use COUNTIFS — the plural — which takes pairs of range and condition:

=COUNTIFS(C2:C500, ">=10", C2:C500, "<=50")

Both conditions apply to the same range here, which makes it a band count. Add more pairs for more conditions, for example only counting rows in a region:

=COUNTIFS(C2:C500, ">=10", C2:C500, "<=50", B2:B500, "North")

Note the quotes around the comparison: ">=10" is text as far as Excel is concerned, and the operators have to be inside it.

Sum the same cell across many sheets #

A 3D reference totals one cell or range over a span of sheets:

=SUM(Jan:Dec!B2)

That adds B2 from every sheet between Jan and Dec, in tab order. It is the fastest way to consolidate a workbook where each month is its own tab, and it updates automatically when a sheet is added inside the range.

If the sheets are not contiguous, list them instead:

=SUM(Jan!B2, Mar!B2, Jul!B2)

Convert dd/mm/yyyy to mm/dd/yyyy #

Two different problems hide behind this question, and the fix depends on which one you have.

If the value is already a date and only displays wrongly, it is a formatting problem — do not touch the formula. Select the cells, press Ctrl+1, and choose the date format you want. Changing the format later never changes the underlying value, which is what you want.

If the value is text that looks like a date — often the result of importing a CSV — convert it with DATEVALUE or rebuild it explicitly:

=DATE(RIGHT(A2,4), MID(A2,4,2), LEFT(A2,2))

That takes 25/12/2026, pulls the year, month and day out by position, and returns a real date that sorts and filters correctly. Use TEXT() only when you need the output as text for a label.

Which one to reach for #

QuestionFunctionWatch for
How many rows say X?COUNTIFQuotes around comparisons
How many between A and B?COUNTIFSSame range twice, two conditions
Hide the errorIFERRORIt hides real errors as well as expected ones
Total one cell across tabsSUM with 3D referenceSheets must sit between the named ones
Fix a date that will not sortDATE or DATEVALUECheck whether it is text first

Frequently asked #

Why does COUNTIF return 0 when I can see the matches? #

Almost always stray spaces or numbers stored as text. Check with =ISTEXT(A2) on a suspect cell, and clean with TRIM() or Text to Columns.

Why does my 3D reference miss a sheet? #

Because the missing sheet sits outside the range you named. Jan:Dec!B2 covers every tab positioned between Jan and Dec — move a sheet outside that span and it stops counting.

Should I convert dates with a formula or Text to Columns? #

For a one-off import, Text to Columns is faster. For anything that repeats monthly, a formula or Power Query keeps the workbook correct without anyone remembering to run it.

Share to...