Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Function Creator: Build Custom Functions

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

You can create custom functions in Excel without any programming by using the built-in LAMBDA function. LAMBDA lets you define your own reusable function with parameters and a calculation, all inside a normal cell formula. You do not need VBA, macros, or add-ins. The only requirement is a Microsoft 365 subscription or Excel 2024, because LAMBDA is not available in older perpetual versions like Excel 2019 or 2016. Once you write a LAMBDA, you can name it and call it anywhere in the workbook, just like SUM or AVERAGE. This guide walks you through creating, naming, and using a custom function step by step, and covers the common mistakes and troubleshooting you will hit along the way.

What You'll Need

  • Excel for Microsoft 365 (Windows or Mac), Excel 2024, or Excel for the web. LAMBDA is not supported in Excel 2021, 2019, or earlier.
  • A workbook where you want to use the function. The function will be available only in that workbook unless you copy it to another.
  • Basic familiarity with Excel formulas and cell references.

Step-by-Step

  1. Open the Name Manager. Go to the Formulas tab on the ribbon and click Name Manager. (On Mac, the same button is on the Formulas tab.) If you prefer keyboard, press Ctrl+F3 on Windows or Cmd+F3 on Mac. Labels can differ slightly by version and region, but Name Manager is present in all supported builds.
  2. Click New. In the Name Manager dialog, click the New button. This opens the New Name dialog where you define the function.
  3. Enter a function name. In the Name box, type a name with no spaces, such as TAXRATE or CONVERTUNITS. Names must start with a letter or underscore, cannot look like a cell reference (so avoid names like A1 or R1C1), and cannot contain spaces or most punctuation. Use underscores if you need separation, e.g., SALES_TAX.
  4. Write the LAMBDA formula in the Refers to box. The syntax is =LAMBDA(parameter1, parameter2, calculation). For example, to create a function that adds sales tax to a price: =LAMBDA(price, rate, price * (1 + rate)). Parameters are names you choose; they act like placeholders. The calculation uses those parameter names. You can have up to 253 parameters, but most functions need only one to three.
  5. Test the LAMBDA before saving. Close the New Name dialog by clicking OK, then in any cell type =TAXRATE(100, 0.08) and press Enter. If you see 108, the function works. If you see #VALUE! or #NAME?, check for typos in the parameter names or missing commas. You can also test a LAMBDA directly in a cell without naming it first: type =LAMBDA(x, x*2)(5) and press Enter; it should return 10. This is useful for debugging before you commit the name.
  6. Use the function anywhere in the workbook. Once named, type =TAXRATE(A2, B2) in any cell. The function behaves like a native Excel function: it appears in formula autocomplete after you type the first few letters, and it recalculates automatically when inputs change.
  7. Edit or delete the function. Open Name Manager again, select the name, and click Edit or Delete. Editing lets you change the LAMBDA formula or parameters. Deleting removes the name; any cells using it will show #NAME? until you re-create it or replace the formula.
  8. Share the function with others. Named LAMBDAs are stored in the workbook, so anyone who opens the file can use them. To move a function to another workbook, copy a cell that uses it, paste into the target workbook, then open Name Manager there and create the same name with the same LAMBDA formula. There is no built-in export button; copying the definition is the standard method.

Common Mistakes

  • Using a name that looks like a cell reference. Excel rejects names like A1, R1C1, or C3. Use descriptive names such as UNIT_PRICE or TAX_CALC.
  • Forgetting the equals sign. The Refers to box must start with =LAMBDA(...). Without the equals sign, Excel treats the text as a static value, not a formula.
  • Mismatched parameter count. If your LAMBDA has two parameters, you must supply two arguments when calling it. Calling =TAXRATE(100) when the function expects (price, rate) returns #VALUE!.
  • Using cell references instead of parameter names inside the LAMBDA. Inside =LAMBDA(price, rate, price * (1 + rate)), the words price and rate are placeholders. If you accidentally write A2 * (1 + B2), the function will always read those fixed cells, not the arguments you pass in.
  • Assuming the function travels with Excel. Named LAMBDAs live in the workbook. Opening a new blank workbook will not show your custom function; you must copy the definition or open the original file.
  • Expecting LAMBDA in older Excel. Excel 2021, 2019, and earlier do not support LAMBDA at all. Typing =LAMBDA there returns #NAME?. The only workaround is VBA, which is a different approach and requires macro-enabled files.

Tips

  • Keep parameter names short but meaningful: price, qty, rate. They appear in the formula bar when someone edits the function, so clarity helps.
  • Build and test the LAMBDA in a cell first using the immediate-call pattern =LAMBDA(x, x*2)(5). Once it returns the right result, copy the LAMBDA part into Name Manager.
  • Use descriptive function names in all caps to match Excel's built-in style, e.g., CALC_TAX rather than calcTax.
  • Document your function by adding a comment in a nearby cell or a note in the workbook, since Name Manager does not have a description field for LAMBDAs.
  • If you need the same function across many workbooks, store the definition in a text file or a template workbook, then paste it into Name Manager when needed.
  • LAMBDA can call other LAMBDAs. For example, a function that applies tax and then rounds can reference a separate ROUNDUP function you defined earlier. This lets you build small, testable pieces.

Troubleshooting

If the function returns #NAME?, the name is either misspelled in the cell or not defined in Name Manager. Open Name Manager and confirm the exact spelling. If it returns #VALUE!, check that the number of arguments matches the number of parameters and that each argument is a valid value. If you see #CALC! or a circular reference warning, your LAMBDA may be referring to the cell it sits in; rewrite the calculation to use only its parameters. If the function works in one workbook but not another, the name was not copied; re-create it in the target workbook. If Excel refuses to save the name, the name likely conflicts with a cell reference or contains a space; rename it. Finally, if LAMBDA is not recognized at all, check your Excel version under File > Account; LAMBDA requires Microsoft 365 or Excel 2024.

Frequently Asked Questions

Can I create a custom function without VBA?

Yes, using the LAMBDA function in Excel for Microsoft 365 or Excel 2024. You define parameters and a calculation, then name it in Name Manager. No macros or programming are required.

Does a named LAMBDA work in other workbooks?

No, not automatically. Named LAMBDAs are stored in the workbook where you created them. To use one elsewhere, copy a cell that contains the function, paste it into the other workbook, and re-create the name in that workbook's Name Manager.

Why does my LAMBDA show #NAME? after I name it?

Usually a spelling mismatch between the name in Name Manager and the name you typed in the cell, or the name was not saved. Open Name Manager, verify the exact spelling, and retype the formula in the cell.

Can I use LAMBDA in Excel 2019 or 2021?

No. LAMBDA is not available in those versions. It requires Microsoft 365, Excel 2024, or Excel for the web. In older versions you would need VBA to build a custom function.

How many parameters can a LAMBDA have?

Up to 253 parameters, though most practical functions use one to three. Each parameter is a name you choose, and you must supply the same number of arguments when calling the function.

Can I delete a custom function I no longer need?

Yes. Open Name Manager, select the name, and click Delete. Any cells still using it will show #NAME? until you replace the formula or re-create the function.