## Strategic Decision Making Visual Basic Code

You can obtain the Visual Basic code used in Strategic Decision Making: Multiobjective Decision Analysis with Spreadsheets from this page in either of the two ways listed below. (The bibliographic citation for this book is Craig W. Kirkwood, Strategic Decision Making: Multiobjective Decision Analysis with Spreadsheets, Duxbury Press, Belmont, CA, 1997, ISBN 0-534-51692-0.)

If you are using Excel 97, consult "Excel 97 Display Bug" for information about a bug in Excel 97. One way to work around this bug is to modify the code for these Visual Basic functions, as discussed on that web page.

2. Copy the Visual Basic code below into the Clipboard, and then paste it into an Excel macro module. (Note: Copy this code directly from the page below. Do not copy it from the html source page because that contains special coding necessary for the ``greater than'' sign in html.)

```Function ValuePL(x, Xi, Vi)
i = 2
Do While x >  Xi(i)
i = i + 1
Loop
ValuePL = Vi(i - 1) _
+ (Vi(i) - Vi(i - 1)) * (x - Xi(i - 1)) / (Xi(i) - Xi(i - 1))
End Function

Function ValueE(x, Low, High, Monotonicity, Rho)
Select Case UCase(Monotonicity)
Case "INCREASING"
Difference = x - Low
Case "DECREASING"
Difference = High - x
End Select
If UCase(Rho) = "INFINITY" Then
ValueE = Difference / (High - Low)
Else
ValueE = (1 - Exp(-Difference / Rho)) / (1 - Exp(-(High - Low) / Rho))
End If
End Function

Function CEValue(RhoM, Weight, Pi, Vi)
If UCase(RhoM) = "INFINITY" Then
CEValue = Weight * Application.SumProduct(Pi, Vi)
Else
EV = 0
For i = 1 To Application.Count(Pi)
EV = EV + Pi(i) * Exp(-Weight * Vi(i) / RhoM)
Next i
CEValue = -RhoM * Log(EV)
End If
End Function