Macro Language?

JustGANDES

New Member
Joined
Feb 11, 2014
Messages
6
Hi there,

I'm working on a spreadsheet that I didn't create and wanted to understand how the macro works on the spreadsheet. Some of the language in the macro makes sense to me, but the majority of it doesn't. Would it be possible for someone to look over this and in each section, let me know what it means (what the function is?). Any information you can provide would be GREATLY appreciated!!! Thank you so much!

Function utilisation(Intensity As Double, agents As Long) As Double
'Copyright Expedio Virtual Assistance Ltd 2008
'calculates utilisation or agent occupancy
On Error GoTo utilisationerror
utilisation = Intensity / agents

utilisationexit:
If utilisation < 0 Then utilisation = 0
If utilisation > 1 Then utilisation = 1
Exit Function

utilisationerror:
utilisation = 0
Resume utilisationexit
End Function

-------------------------------------------------------------------------------------------------------------------
Function top(Intensity As Double, agents As Long) As Double
'Copyright Expedio Virtual Assistance Ltd 2008
'top row of Erlang-C Formula
top = (Intensity ^ agents) / Application.WorksheetFunction.Fact(agents)
End Function

------------------------------------------------------------------------------------------------------------------
Function erlangBR(Intensity As Double, agents As Long) As Double
'Copyright Expedio Virtual Assistance Ltd 2008
'calculates summed factorial element of Erlang-C formula
Dim k As Long, max As Long, answer As Double

k = 0
max = agents - 1
answer = 0

For k = 0 To max
answer = answer + ((Intensity ^ k) / Application.WorksheetFunction.Fact(k))
Next k

erlangBR = answer

End Function

-----------------------------------------------------------------------------------------------------------------------
Function ErlangC(Intensity As Double, agents As Long) As Double
'Copyright Expedio Virtual Assistance Ltd 2008
'Brings together elements of Erlang C formula Top, Utilisation and ErlangBR
On Error GoTo ErlangCError
ErlangC = (top(Intensity, agents)) / ((top(Intensity, agents)) + ((1 - utilisation(Intensity, agents)) * erlangBR(Intensity, agents)))

ErlangCExit:
If ErlangC < 0 Then ErlangC = 0
If ErlangC > 1 Then ErlangC = 1
Exit Function

ErlangCError:
Resume ErlangCExit

End Function

-----------------------------------------------------------------------------------------------------------------------
Function Servicelevel(Intensity As Double, agents As Long, target As Double, duration As Double) As Double
'Copyright Expedio Virtual Assistance Ltd 2008
'calculation of service level
On Error GoTo servicelevelerror

Servicelevel = 1 - (ErlangC(Intensity, agents) * Exp(-(agents - Intensity) * target / duration))

Servicelevelexit:
If Servicelevel > 1 Then Servicelevel = 1
If Servicelevel < 0 Then Servicelevel = 0
Exit Function

servicelevelerror:
Servicelevel = 0
Resume Servicelevelexit

End Function


------------------------------------------------------------------------------------------------------------------------
Function agentno(Intensity As Double, target As Double, duration As Double, servreq As Double) As Long
'Copyright Expedio Virtual Assistance Ltd 2008
'calculates minimum agent numbers for required service level
Dim agents As Long, minagents As Long

minagents = Int(Intensity)
agents = minagents

While Servicelevel(Intensity, agents, target, duration) < servreq
agents = agents + 1
Wend

agentno = agents
End Function

----------------------------
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Some of those are decidedly overkill, and use GoTo unnecessarily. The first one could be reduced to this:

Code:
Function utilisation(Intensity As Double, agents As Long) As Integer
On Error Resume Next
utilisation = -((Intensity / agents) > 1)
End Function
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,021
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top