You can implement the Erlang C formula in VBA by writing a custom function that computes the probability a call must wait, then using it to derive service level and staffing numbers. The shortest working path is: open the VBA editor with Alt+F11, insert a module, paste a function that calculates Erlang C from offered load and agent count, then call it from a worksheet cell. This guide walks through that build, the inputs you need, and the mistakes that make the result look wrong.
What You'll Need
- Excel on Windows or Mac with macros enabled (the VBA editor is not available in Excel for the web).
- Your call volume for the period, average handle time (AHT) in the same time unit, and the number of agents or trunks you want to test.
- A workbook saved as .xlsm so the code persists.
- Basic familiarity with the VBA editor: Alt+F11 opens it, and Insert > Module adds a blank code pane.
Step-by-Step
- Enable the Developer tab. Go to File > Options > Customize Ribbon and tick Developer in the right-hand list. On Mac, Excel > Preferences > Ribbon & Toolbar. Labels vary slightly by version, but the Developer tab is where the Visual Basic button lives.
- Open the VBA editor. Press Alt+F11 (on Mac, Fn+Alt+F11 or the Developer > Visual Basic button). In the Project pane, find your workbook.
- Insert a module. Right-click the workbook name, choose Insert > Module. A blank code window appears. Everything below goes there.
- Add a helper for the Erlang B recursion. Erlang C is built from Erlang B, and the stable way to compute B is the recursive form. Paste this function:
Function ErlangB(agents As Double, load As Double) As Double Dim b As Double, i As Long b = 1 For i = 1 To agents b = (load * b) / (i + load * b) Next i ErlangB = b End Function - Add the Erlang C function. Erlang C is C = B / (1 - (load/agents) * (1 - B)). Paste:
Function ErlangC(agents As Double, load As Double) As Double Dim b As Double If agents <= load Then ErlangC = 1 Exit Function End If b = ErlangB(agents, load) ErlangC = b / (1 - (load / agents) * (1 - b)) End FunctionThe guard clause matters: if agents are at or below the offered load, the queue is unstable and the probability of waiting is effectively 100%. - Work out the offered load. Load in Erlangs = (calls per period × AHT in seconds) / period length in seconds. For 200 calls in an hour with a 180-second AHT: (200 × 180) / 3600 = 10 Erlangs. Put calls, AHT and period in separate cells so you can change them.
- Call the function from a cell. In an empty cell type =ErlangC(12,10) for 12 agents and 10 Erlangs. The result is the probability a caller waits. Format the cell as a percentage.
- Build the service level line. Service level = 1 - ErlangC × EXP(-(agents - load) × target seconds / AHT). With 12 agents, 10 Erlangs, 180-second AHT and a 20-second target, that gives roughly 1 - 0.43 × EXP(-(2 × 20)/180), about 61%. Put target seconds in its own cell and reference it.
- Add average wait for those who wait. ASA = ErlangC × AHT / (agents - load). With the same numbers, 0.43 × 180 / 2 seconds, about 39 seconds. This is the wait among callers who queue, not the average across all callers.
- Test a staffing table. List agent counts from, say, 10 to 20 down one column and copy the ErlangC formula beside each. You will see the probability fall sharply once agents exceed load, which is the curve planners use to pick a headcount.
- Save as .xlsm. File > Save As, choose Excel Macro-Enabled Workbook. A plain .xlsx strips the module on the next open.
Common Mistakes
- Mixing time units. Calls per hour with AHT in minutes gives a load ten times too large. Convert everything to seconds, or everything to minutes, before dividing.
- Passing agents as a decimal. Agent counts must be whole numbers; a fractional value breaks the recursion and returns nonsense.
- Forgetting the guard clause. Without the agents <= load check, the formula divides by near-zero and returns an error or a huge number.
- Treating Erlang C output as average wait. The function returns the probability of waiting, not the wait time. ASA is a separate calculation.
- Using Erlang C for abandoned calls. Erlang C assumes no one hangs up and no blocked calls. Where abandonment is material, the result overstates staffing need.
- Losing the code. Saving as .xlsx or sharing the file without the module loses the function for everyone else.
Tips
- Name your input cells (Formulas > Define Name) so formulas read =ErlangC(Agents, Load) instead of cell addresses.
- Add a Data Validation list for agent counts so nobody types a decimal by accident.
- Keep a second sheet with the raw volume and AHT data, and let the calculation sheet reference it. That makes month-to-month comparisons easy.
- Round displayed results to two decimals; the underlying value stays precise for further maths.
- If you need to model shrinkage (breaks, meetings, absence), divide the required agents by (1 - shrinkage) after you have the Erlang C answer.
Troubleshooting
If the cell shows #NAME?, the module did not save or macros are disabled. Check File > Options > Trust Center > Macro Settings and confirm the workbook is .xlsm. If you get #VALUE!, one argument is text or blank; check the referenced cells. If the result is 100% for every agent count, your load exceeds agents in every row, so extend the agent list upward. If the number looks plausible but the service level is wrong, recheck the target seconds and AHT are in the same unit. If the file opens with a macro warning on another machine, that is normal; the user must enable content. If the function disappears after an Excel update, reopen the .xlsm and re-enable macros; the code is still in the module.
Frequently Asked Questions
Does Erlang C work in Excel for the web?
No. The web version cannot run VBA modules. Use desktop Excel, or rebuild the formula with native worksheet functions.
What is the difference between Erlang B and Erlang C?
Erlang B models blocked calls with no queue; Erlang C models calls that wait in a queue. Contact centres use C, trunk sizing often uses B.
Can I use Erlang C for chat or email?
It is designed for synchronous voice queues. For chat and email, concurrent capacity and response-time targets change the maths, so treat Erlang C as an approximation at best.
Why does my service level not match my workforce tool?
Small differences usually come from rounding, from whether shrinkage is applied before or after, and from whether the tool uses average or interval-by-interval volumes.
How many agents do I need for an 80/20 service level?
There is no single number; it depends on load and AHT. Build the staffing table in step 10 and read off the smallest agent count whose service level cell meets your target.
Is the Erlang C formula stable for very large agent counts?
The recursive Erlang B form used here is stable for normal contact-centre sizes. For very large numbers, watch for floating-point rounding and compare against a known reference.