Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 187
Default calculating weighted average cost of capital in a macro

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default calculating weighted average cost of capital in a macro

Use a userform to get all the data at once. Here is some info:

http://j-walk.com/ss/excel/tips/tip84.htm

http://www.contextures.on.ca/xlUserForm01.html


See this tutorial here
http://www.dicks-blog.com/excel/2004...g_userfor.html

http://support.microsoft.com/default...b;en-us;829070
How to use Visual Basic for Applications examples to control UserForms in
Microsoft Excel


XL97: How to Use a UserForm for Entering Data (Q161514)
http://support.microsoft.com/?id=161514

XL2000: How to Use a UserForm for Entering Data (Q213749)
http://support.microsoft.com/?id=213749


http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection


Here are some other sources of information:

http://www.microsoft.com/ExcelDev/Articles/sxs11pt1.htm
Lesson 11: Creating a Custom Form
Excerpted from Microsoft® Excel 97 Visual Basic® Step by Step.


http://support.microsoft.com/?id=168067
File Title: Microsoft(R) Visual Basic(R) for Applications Examples for
Controlling UserForms in Microsoft Excel 97
File Name: WE1163.EXE
File Size: 161742 bytes
File Date: 05/08/97
Keywords: kbfile
Description: This Application Note is an introduction to manipulating
UserForms in Microsoft Excel 97. It includes examples and Microsoft Visual
Basic for Applications macros that show you how to take advantage of the
capabilities of UserForms and use each of the ActiveX controls that are
available for UserForms

--
Regards,
Tom Ogilvy


"Dave F" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 187
Default calculating weighted average cost of capital in a macro

Thanks, I think this is the sort of info I was looking for.

Dave

On Aug 6, 3:02 pm, Tom Ogilvy
wrote:
Use a userform to get all the data at once. Here is some info:

http://j-walk.com/ss/excel/tips/tip84.htm

http://www.contextures.on.ca/xlUserForm01.html

See this tutorial herehttp://www.dicks-blog.com/excel/2004/09/linking_userfor.html

http://support.microsoft.com/default...b;en-us;829070
How to use Visual Basic for Applications examples to control UserForms in
Microsoft Excel

XL97: How to Use a UserForm for Entering Data (Q161514)http://support.microsoft.com/?id=161514

XL2000: How to Use a UserForm for Entering Data (Q213749)http://support.microsoft.com/?id=213749

http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection

Here are some other sources of information:

http://www.microsoft.com/ExcelDev/Articles/sxs11pt1.htm
Lesson 11: Creating a Custom Form
Excerpted from Microsoft® Excel 97 Visual Basic® Step by Step.

http://support.microsoft.com/?id=168067
File Title: Microsoft(R) Visual Basic(R) for Applications Examples for
Controlling UserForms in Microsoft Excel 97
File Name: WE1163.EXE
File Size: 161742 bytes
File Date: 05/08/97
Keywords: kbfile
Description: This Application Note is an introduction to manipulating
UserForms in Microsoft Excel 97. It includes examples and Microsoft Visual
Basic for Applications macros that show you how to take advantage of the
capabilities of UserForms and use each of the ActiveX controls that are
available for UserForms

--
Regards,
Tom Ogilvy



"Dave F" wrote:
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- Hide quoted text -


- Show quoted text -



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Weighted Average sfmoored Excel Worksheet Functions 7 February 28th 11 03:36 AM
Calculating a weighted average in a pivot table mrogge Excel Discussion (Misc queries) 1 April 16th 09 06:15 PM
calculate weighted average of stock cost Tim Excel Worksheet Functions 14 May 25th 07 11:33 PM
calculating a weighted average using formula bob green Excel Worksheet Functions 1 August 1st 05 10:33 PM
Can you calculate "weighted average cost of capital? Dennis Excel Discussion (Misc queries) 1 June 20th 05 07:33 AM


All times are GMT +1. The time now is 11:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"