Formulas & Excel logic

Formulas in workbooks

Writing formulas with openpyxl, reading cached results, named ranges and recalculation.

openpyxl writes a SUM formula into a cell as text; the value appears only after Excel recalculates, which is why data_only reads return None on a fresh file.openpyxl writes a SUM formula into a cell as text; the value appears only after Excel recalculates, which is why data_only reads return None on a fresh file.write the formula, let Excel do the mathsABCD1ItemPriceQtyTotal2Tea4.5010=B2*C23Mugs8.003=B3*C34Sum=SUM(D2:D3)

Start with the full guides

The long-form treatment of formulas in workbooks, with the reasoning the shorter pages assume.

Step-by-step how-tos

One task each, with code you can copy, run and adapt.

Compare the options

Which tool or approach to pick, and why.

When it breaks

The errors this topic produces, with the cause explained rather than just the fix.

Follow it through a track

Prefer an ordered route? These tracks cover formulas in workbooks along the way, in the order that builds on itself.

Related topics

Subjects that keep turning up on the same pages as this one, most overlap first.

Formulas in workbooks is part of Formulas & Excel logic.