VBA & Macro Problems

Create Custom Worksheet Formulas in Excel with VBA or LAMBDA

Tauseeq MagsiTauseeq Magsi Nov 12, 2026 868 views

Question details

The user wants to create reusable custom formula logic that can be used in Excel worksheets.

Create Custom Worksheet Formulas in Excel with VBA or LAMBDA
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user needs a formula-like function for calculations that are not covered by Excel's built-in worksheet functions.
Observed behavior
Excel does not let users add new native worksheet functions directly, but custom logic can be created with LAMBDA, VBA UDFs, or add-ins.
Before you start

Check which Excel version you use before choosing a method: named LAMBDA functions require a supported Microsoft 365 or newer Excel version. To use VBA, save the workbook as an Excel Macro-Enabled Workbook (.xlsm) and ensure macros are permitted by your organization.

Solution 1Recommended

Create a reusable custom formula with Excel LAMBDA

Use this method when you have a supported Excel version and want to reuse formula logic without writing VBA code.

A named LAMBDA stores a formula under a custom name, so you can call it in cells like a built-in Excel function. The LAMBDA is saved in the workbook unless you store it in a reusable template or add-in.

1
Open Name Manager

In Excel, go to the Formulas tab and select Name Manager, then click New.

2
Create the LAMBDA name

Enter a descriptive name, such as AddTax, in the Name box. In the Refers to box, enter a formula such as =LAMBDA(value,value*1.1).

3
Save the custom function

Click OK, then close Name Manager. The function name is now available in the current workbook.

4
Use the function in a worksheet

Select a cell and enter =AddTax(A1), replacing A1 with the value or cell reference you want to calculate.

Create a reusable custom formula with Excel LAMBDA
Use LAMBDA without macros: Named LAMBDA functions do not require VBA macros, so they are suitable for workbooks where macro execution is restricted.
Free Microsoft Office alternative

Use WPS Spreadsheet for Everyday Excel Formula Work

WPS Office is a free, lightweight office suite with a familiar spreadsheet interface for working with formulas, tables, and Microsoft Excel files. You can move existing workbooks to WPS Spreadsheet seamlessly for standard calculation and worksheet tasks while retaining common Excel file formats.

Free and lightweight spreadsheet software for everyday formula and data tasks.Supports Microsoft Excel XLSX, XLS, and XLSM workbook formats.Familiar ribbon-based interface helps Excel users transition quickly.Provides built-in functions, formula editing, and worksheet tools for calculation workflows.
microsoft office alternative - wps office

Frequently Asked Questions

Can I add a completely new built-in function to Excel?

No. Excel does not allow users to permanently add a new native function to its built-in function library. You can instead create a named LAMBDA, a VBA user-defined function, or an Excel add-in.

Where do I create a LAMBDA function in Excel?

Go to Formulas > Name Manager > New. Enter a function name and define the logic in the Refers to box with the LAMBDA syntax, such as =LAMBDA(x,x*2).

Why does my VBA custom function return #NAME? in Excel?

Confirm that the function is in a standard module under Insert > Module, the workbook is saved as an .xlsm file, macros are enabled, and the formula uses the exact VBA function name.

Can a VBA UDF change another cell's value?

No. A VBA UDF called from a worksheet cell should only return a result. To edit cells, apply formatting, or perform other actions, run a VBA Sub macro from Developer > Macros or a button instead.