Help with VBA user defined function - iterate by date and multiply field of one table by another table

micklebt

New Member
Joined
Nov 25, 2009
Messages
6
My project is the conversion of an investment management decision-making tool from Excel to Access.

I have two Access tables:

[tbl_POSITIONS] records the closing value of each position held at market close daily: eg: 12/15/12, AIGTX, 41.17

[tbl_RETURNS] records the date and amount when dividends, short term capital gains, and long term capital gains are awarded: eg: 12/7/12, AIGTX, .00213

My objective is a UDF which cycles through tbl_POSITIONS, and when a fund and date match are found, from dividend issuance date forward for that fund the function multiplies the NAV (41.17) by the dividend (.00213) each day until a new dividend is issued.

When a new subsequent dividend is awarded, the function will compound the returns by multiplying date period 1 by dividend 1, and date period 2 by dividend 1 +dividend 2.

In English, I believe would go like this: for each holding where tbl_POSITIONS date => tbl_RETURNS date, then multiply NAV x dividend.

When a second dividend date for a given holding is reached, the new multiplier becomes (dividend 1 + dividend 2), and so on.

The intention is a calculated query column which accurately produces calculated NAV on any given date by factoring and applying the issuance of dividends back into the NAV.


Any help is greatly appreciated. Thanks,

Brian

12/10/12VIPSX15.14
12/10/12VFSTX10.88
12/10/12VFINX131.41
12/10/12VISGX24.63
12/10/12VFITX11.84
12/10/12VIGRX36.64
12/10/12VGTSX14.73
12/10/12VGSIX21.65
12/10/12VIMSX22.41
12/10/12WASCX24.98
12/10/12VISVX17.42
12/10/12WBFFX21.51
12/10/12VLACX26.31
12/10/12WAAEX43.30
12/10/12VUSTX13.59

<tbody>
[TH="bgcolor: #c0c0c0"] ClosingDate [/TH]
[TH="bgcolor: #c0c0c0"] Ticker [/TH]
[TH="bgcolor: #c0c0c0"] NAV [/TH]

</tbody>


1/31/2007VBIIX0.0431
1/31/2007VBISX0.0381
1/31/2007VBLTX0.0521
2/16/2007AFIFX0.11921
2/28/2007BPRAX0.0076221
2/28/2007CPTNX0.0381681
2/28/2007FFIHX0.02921
2/28/2007GTDTX0.0293555751
2/28/2007OGGAX0.0381
2/28/2007OIEIX0.023651
2/28/2007VBIIX0.0391
2/28/2007VBISX0.0351
2/28/2007VBLTX0.0471
3/13/2007TWEAX0.01741
3/20/2007SASVX0.0196821
3/21/2007NAESX0.0061

<tbody>
[TH="bgcolor: #c0c0c0"] ClosingDate [/TH]
[TH="bgcolor: #c0c0c0"] Ticker [/TH]
[TH="bgcolor: #c0c0c0"] Returns [/TH]
[TH="bgcolor: #c0c0c0"] ReturnTypeID [/TH]

</tbody>
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
If you have a stock that's paying dividends of 1/5 of a percent on the dollar every day don't stop to write VBA UDFs - at that rate a $40 investment would more than double in a year: $41 * (1 + .002) ^ 365 = $85
 
Upvote 0
Perhaps I'm not clear with my example.

The objective is to track chronologically the changing value of financial holding from it's inception date to present by tracking the posted closing value AND applying any dividends issued from that date forward.

The investment's value changes in two ways, daily increasing or decreasing value at closing bell, and periodic issuance of dividends, splits, etc. We are tracking a net accumulated value over time, which is the reason for my UDF request.

If I knew how to do so, the solution may exist with a query - but that's beyond my ability - which is why I envision a UDF solution. Unfortunately, my vision exceeds my skills in executing! LOL.

Hope this helps anyone else who is able to lend a hand.

Many, many thanks in advance!

Brian
 
Upvote 0
I don't really understand this. Why do you have dividends being issued every day? That doesn't happen. Strictly speaking they aren't part of the stocks value either - they are part of your return but the stock itself represents the value of the company - i.e., in the extreme case if a company liquidates all it's assets and returns them to shareholders as dividends then the stock is worth zero. So you can measure the gain/loss at a given date, and the value of dividends issued, to measure your return (not the value of the stock).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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