Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to write a macro to calculate the weighted average cost of
capital, based on values inputted by the user who executes the macro. Following is the code I have but it occurs to me that this looks rather ungainly. Is there a better way to write code of this sort: Sub CalculateWACC() Dim MyString1 As String, MyString2 As String Dim MyString3 As String, MyString4 As String Dim MyString5 As String 'Prompts the user for values to input to calculate the weighted average 'cost of capital, based on the formula 'c = (E/K) * y + (D/K) * b(1 - t) 'whe K = D + E 'c = weighted average cost of capital (%) 'y = required or expected return on equity (%) 'b = required or expected return on borrowings (%) 't = corporate tax rate (%) 'D = total debt and leases (currency) 'E = total equity and equity equivalents (currency) 'K = total capital invested in the going concern (currency) MyString1 = Application.InputBox("enter required or expected return on equity") MyString2 = Application.InputBox("enter required or expected return on debt") MyString3 = Application.InputBox("enter corporate tax rate") MyString4 = Application.InputBox("enter total debt and leases") MyString5 = Application.InputBox("enter total equity and equity equivalents") Worksheets("Analysis").Range("A1") = MyString1 Worksheets("Analysis").Range("A2") = MyString2 Worksheets("Analysis").Range("A3") = MyString3 Worksheets("Analysis").Range("A4") = MyString4 Worksheets("Analysis").Range("A5") = MyString5 Worksheets("Analysis").Range("A6") = "SUM(A4+A5)" End Sub Thanks |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating Weighted Average | Excel Worksheet Functions | |||
Calculating a weighted average in a pivot table | Excel Discussion (Misc queries) | |||
calculate weighted average of stock cost | Excel Worksheet Functions | |||
calculating a weighted average using formula | Excel Worksheet Functions | |||
Can you calculate "weighted average cost of capital? | Excel Discussion (Misc queries) |