Calculating Yield in VBA

JohnAndersen

New Member
Joined
Feb 4, 2011
Messages
10
All,

I am importing raw trade data into excel where I then need to run yield calculations. This is where I am getting hung up. Although there is a yield function in the worksheet there doesn't appear to be anything equivalent when I try to write it up in VBA. The Analysis Toolpak for VBA is loaded and everything but it still won't work.

Does anyone know anything about this? Has anyone done tried to calculate anything similar where they've gotten around this?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi

In the VBE, do you have a reference set to atpvbaen.xls in Tools>References? You need this to access the ATP VBA Yield function. You don't call it as a Worksheetfunction:

Code:
MsgBox Yield(settlement,maturity,rate,pr,redemption,frequency,basis)
 
Upvote 0
To use Analysis ToolPak functions in VBA, first install the Add-In 'Analysis ToolPak - VBA', then, with your workbook selected in the Visual Basic Editor, set a reference to atpvbaen.xls.
 
Upvote 0
To use Analysis ToolPak functions in VBA, first install the Add-In 'Analysis ToolPak - VBA', then, with your workbook selected in the Visual Basic Editor, set a reference to atpvbaen.xls.


I understand how to use the analysis toolpak functions and how to set up a reference. The issue is that where there is a YIELD function in the worksheet (for an interest paying bond), there isn't an equivalent in VBA that I can find. YieldDisc is for a discounted security and YieldMat is for a bond that only pays interest at maturity.
 
Upvote 0
Hi

In the VBE, do you have a reference set to atpvbaen.xls in Tools>References? You need this to access the ATP VBA Yield function. You don't call it as a Worksheetfunction:

Code:
MsgBox Yield(settlement,maturity,rate,pr,redemption,frequency,basis)


I am running Excel 2007 and don't see the yield function.
 
Upvote 0
Yield appears as a member of the <Globals> class of atpvbaen.xls in the Object Browser (above the two functions you mentioned). It's syntax is as posted by Richard.
 
Upvote 0

Forum statistics

Threads
1,215,986
Messages
6,128,115
Members
449,423
Latest member
Mike_AL

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