What Most People Miss About How to Define Function in Excel

It’s 3:12 PM. You’re auditing Q2 vendor payments for Acme Corp. Three spreadsheets open. You need to calculate late-fee penalties using a custom formula: if invoice date is more than 30 days past due, charge 1.8% per month on the unpaid balance. You’ve typed it into cell D2 — then realize you’ll need it in 47 more rows. Copy-paste won’t cut it if logic changes later. You need to define a function — not just use one.

Quick Answer

You don’t ‘define’ functions like in programming languages. In Excel, you create reusable logic by naming formulas (via Name Manager) or building custom functions using LAMBDA (Excel 365/2021+). LAMBDA lets you write =LATEFEE(A2,B2,C2) instead of =IF(TODAY()-A2>30,(B2*C2*0.018*ROUNDUP((TODAY()-A2)/30,0)),0). That’s what ‘defining a function’ actually means in Excel — and only two methods deliver real reusability.

All the Methods

Method Steps Best For Limitations
Name Manager (Named Formula) 1. Formulas → Name Manager → New
2. Name: LATEFEE
3. Refers to: =IF(TODAY()-Sheet1!$A2>30,(Sheet1!$B2*Sheet1!$C2*0.018*ROUNDUP((TODAY()-Sheet1!$A2)/30,0)),0)
Simple logic reuse across sheets; no LAMBDA license required No true parameters — relies on relative cell references; breaks if used outside same row context
LAMBDA Function 1. Define via Name Manager → New
2. Name: LATEFEE
3. Refers to: =LAMBDA(invoice_date,amount,rate, IF(TODAY()-invoice_date>30, amount*rate*ROUNDUP((TODAY()-invoice_date)/30,0), 0))
True parameterized functions; portable, testable, composable Requires Microsoft 365 or Excel 2021; won’t work in Excel for Web legacy mode or older desktop versions
VBA User-Defined Function (UDF) 1. Alt+F11 → Insert → Module
2. Paste: Function LATEFEE(invoice_date, amount, rate)
  If Date - invoice_date > 30 Then
    LATEFEE = amount * rate * Application.RoundUp((Date - invoice_date) / 30, 0)
  Else: LATEFEE = 0: End If
Full programming control; works in all Excel desktop versions Macros disabled by default; security warnings; doesn’t recalc automatically when referenced cells change unless volatile functions used
Power Query Custom Function 1. Data → Get Data → Launch Power Query Editor
2. Advanced Editor → paste M code with (invoice_date as date, amount as number, rate as number) => ...
Data transformation pipelines; ideal for ETL-heavy workflows Only usable inside Power Query — can’t be called from worksheet cells like =LATEFEE(A2,B2,C2)

Method 1 Deep Dive

LAMBDA is the only method that truly defines a function — with named, ordered parameters, no hidden row dependencies, and full IntelliSense support.

Start with this raw data in Sheet1, A1:C6:

Invoice Date Amount Due Monthly Rate
2024-01-15 $12,450.00 1.8%
2024-02-03 $8,920.00 1.8%
2024-03-22 $15,600.00 1.8%
2024-01-30 $3,200.00 1.8%
2024-04-10 $7,145.00 1.8%

Now define the function:

  1. Press Ctrl+F3 (or go Formulas → Name Manager → New)
  2. Name: LATEFEE
  3. In “Refers to”, paste this exact formula:
    =LAMBDA(invoice_date,amount,rate, IF(TODAY()-invoice_date>30, amount*rate*ROUNDUP((TODAY()-invoice_date)/30,0), 0))
  4. Click OK. Done.

Now test it. In cell D2, type =LATEFEE(A2,B2,C2). It returns $747.00. Drag down to D6. All values update instantly.

Counterintuitive tip: You can test LAMBDA logic *before* naming it. Type this directly in any blank cell:
=LET(fn,LAMBDA(invoice_date,amount,rate,IF(TODAY()-invoice_date>30,amount*rate*ROUNDUP((TODAY()-invoice_date)/30,0),0)), fn(A2,B2,C2))
This runs the function inline — no Name Manager needed. Use it to validate syntax before committing.

Method 2 Deep Dive

Name Manager formulas look like functions but behave like smart cell references. They’re fragile — and most people don’t realize why.

Use the same data (A1:C6 above). Go to Formulas → Name Manager → New.

  • Name: LATEFEE_NM
  • Refers to:
    =IF(TODAY()-Sheet1!$A2>30,Sheet1!$B2*Sheet1!$C2*0.018*ROUNDUP((TODAY()-Sheet1!$A2)/30,0),0)

Now type =LATEFEE_NM in cell D2. It works. So does D3. But try typing =LATEFEE_NM in cell Z100. It fails — returning #VALUE! — because the formula still points to row 2 ($A2), not Z100’s row.

The fix? Remove all absolute row locks. Change $A2 to A2, $B2 to B2, etc. But now it only works if you call it from the *same row* where the source data lives.

So if you enter =LATEFEE_NM in D2, Excel interprets A2 as “the cell one column left in the same row”. That’s why it seems to work — until you copy it somewhere else or insert rows.

Here’s the hard truth: Named formulas are not functions. They’re shorthand for relative references. Don’t use them for cross-sheet or dynamic-row logic. Reserve them for constants (VAT_RATE = 0.075) or static lookups (REGION_LIST = Sheet2!$A$2:$A$12).

Cheat Sheet

Task Shortcut / Steps Notes
Open Name Manager Ctrl + F3 Fastest way to manage names and LAMBDA definitions
Define LAMBDA In Name Manager → New → Name: MYFUNC → Refers to: =LAMBDA(x,y,x+y) Parameters must be comma-separated, no types, no defaults
Test LAMBDA without naming =LET(f,LAMBDA(a,b,a*b), f(12,5)) Returns 60. No Name Manager needed.
Call your LAMBDA Type =MYFUNC(A2,B2) — Excel shows parameter hints Hints appear only after opening parenthesis — no tooltip unless named
Edit LAMBDA Ctrl+F3 → select name → Edit → update “Refers to” → OK Changes apply instantly — no restart required
Check version File → Account → About Excel → look for “Microsoft 365” or “Excel 2021” LAMBDA not available in Excel 2019 or earlier
Rachel Torres

Rachel Torres

Rachel coaches teams on email management and digital communication best practices. She has trained over 5