Skip to main content

Focused Functions Editor

Python for Excel also includes a focused Editor workflow for creating reusable Python functions that behave like native Excel formulas. This path is separate from notebook-published BF.FUNCTION() functions and remains useful when the desired artifact is a calculation rather than a complete notebook application.

Quick example

def hello(name):
"""Return a greeting."""
return f"Hello {name}!"
=HELLO("World")

Create and save a function

  1. Open the Editor tab.
  2. Write a standard Python function with explicit parameters.
  3. Save the function to workbook settings.
  4. Type the function directly in a cell or insert it through the Function Dialog.

Python Editor

Function arguments and results

Excel inputPython value
Numberfloat
Textstr
Booleanbool
Empty cellNone
Multi-cell rangeTwo-dimensional list

Supported results include numbers, strings, booleans, None, dates, and rectangular arrays that can spill into the worksheet.

Insert a function

Function Search

Function Selected

Enter values directly or select worksheet ranges:

Range Selection

Test Values with Arrays

Insert options

OptionBehaviorBest for
Insert as FormulaInserts a live custom-function formula.Reusable worksheet calculations
Insert as ResultCalculates once and writes the static value.Frozen outputs
Insert as Excel PYInserts a native Microsoft =PY(...) formula when compatible.Workbooks standardized on Microsoft Python in Excel

Console and errors

Console Output

For new multi-cell applications, start with the Notebook workflow. Use the focused Editor when a standalone worksheet function is the better abstraction.