Function Problems

How to Create Custom Excel LAMBDA Functions for Dice Rolls

Camila MilosovichCamila Milosovich Nov 3, 2026 870 views

Question details

The user wants to create custom Excel functions using LAMBDA to easily simulate single or multiple dice rolls for tabletop games like Dungeons & Dragons.

How to Create Custom Excel LAMBDA Functions for Dice Rolls
Product
Excel
Device & OS
not provided
Scenario
Setting up a spreadsheet to simulate customized dice mechanics (e.g., rolling a specific number of dice with varying sides) without repeatedly typing complex formulas.
Observed behavior
Users need to define reusable functions like DIE(x) and DICE(x,y) to streamline random number generation, or find simple formula alternatives if LAMBDA is not available.
Before you start

Verify that your version of Excel supports the LAMBDA and MAKEARRAY functions, which are primarily available in Microsoft 365. If you are using an older version, you can utilize the RANDBETWEEN alternative instead.

Solution 1Recommended

Define Custom DIE and DICE Functions Using LAMBDA

Use the Name Manager to create custom, reusable LAMBDA functions for single and multi-dice rolls.

The LAMBDA function allows you to create your own custom functions without using VBA. By combining it with RANDBETWEEN and MAKEARRAY, you can build powerful dice-rolling tools right in the spreadsheet.

1
Open Name Manager

Navigate to the Formulas tab on the Excel ribbon and click on 'Name Manager'. Click 'New' to create a new defined name.

2
Create the Single Die Function

In the Name box, type 'DIE'. In the 'Refers to' field, enter the formula: =LAMBDA(x,RANDBETWEEN(1,x)). Click OK to save the function.

3
Create the Multi-Dice Function

Click 'New' again. Name this function 'DICE'. In the 'Refers to' field, enter: =LAMBDA(x,y,SUM(MAKEARRAY(1,y,LAMBDA(r,c,RANDBETWEEN(1,x))))). Click OK to save.

4
Use the Functions in Your Sheet

You can now type =DIE(20) into any cell to roll a single 20-sided die, or type =DICE(6,3) to roll three 6-sided dice and calculate the total automatically.

Define Custom DIE and DICE Functions Using LAMBDA
Simulate Dice Rolls in WPS

Easily Simulate Dice Rolls for Games in WPS Office

WPS Spreadsheet provides robust formula capabilities, including RANDBETWEEN, so you can quickly set up dynamic dice-rolling mechanics for tabletop games like Dungeons & Dragons for free.

  1. 1. Create a Drop-Down List: Open WPS Spreadsheet, select cell A1, go to the Data tab, and click Validation. Select List and input '4,6,8,12,20,100'.
  2. 2. Enter the Roll Formula: Click on cell B1 and input the formula =RANDBETWEEN(1,A1) to reference your chosen die size.
  3. 3. Roll and Recalculate: Select a die from your drop-down list. Press the F9 key anytime you want to roll the die again and generate a new result.
Fully compatible with Microsoft Excel formulas like RANDBETWEEN and dynamic cell references.Clean, intuitive interface for setting up Data Validation drop-downs easily.Lightweight and completely free to use for personal gaming and data projects.
microsoft office alternative - wps office

Frequently Asked Questions

Why do my custom LAMBDA functions return a #NAME? error?

This error usually occurs if your version of Excel does not support the LAMBDA function, or if the function hasn't been properly defined in the Name Manager. Ensure you are using a compatible version (like Microsoft 365) and double-check the spelling in the Name box.

How do I roll multiple dice using the simple RANDBETWEEN alternative?

To roll multiple dice without LAMBDA, you can simply add multiple RANDBETWEEN formulas together in the same cell. For example, to roll three 6-sided dice, type =RANDBETWEEN(1,6) + RANDBETWEEN(1,6) + RANDBETWEEN(1,6).

Will the dice roll result change automatically?

Yes. Functions like RANDBETWEEN and RANDARRAY are volatile, which means they recalculate and generate a new random number every time any change is made to the worksheet, or when you manually trigger a recalculation by pressing the F9 key.