Hey,
Hope everyone is doing okay and keeping safe
I have been tasked to make a Fund Performance dashboard using VBA I am able to get stock data from yahoo. Also managed to calcuated monthly returns from daily NAVs. However I am struggling to calculate Quarterly returns.
Here is the code. Though this works in calculating quarterly returns the issue is it repeats. Here is a picture (practice file cant mention real returns)
It calculates the monthly returns, but for quarterly retuns I only want for actual quarter ends in a financial year in a year. However here is it calculating for every month
If anyone can guide me it can be of great help. Thanks
Hope everyone is doing okay and keeping safe
I have been tasked to make a Fund Performance dashboard using VBA I am able to get stock data from yahoo. Also managed to calcuated monthly returns from daily NAVs. However I am struggling to calculate Quarterly returns.
Here is the code. Though this works in calculating quarterly returns the issue is it repeats. Here is a picture (practice file cant mention real returns)
It calculates the monthly returns, but for quarterly retuns I only want for actual quarter ends in a financial year in a year. However here is it calculating for every month
If anyone can guide me it can be of great help. Thanks
VBA Code:
Sub Button2_Click()
Worksheets("Prac").Activate
Dim old_ As Double
Dim new_ As Double
Dim start_row As Integer
start_row = 4
' Track the number of rows
Dim num_row As Integer
num_row = 0
While (Not (IsEmpty(Cells(start_row + num_row, "G"))) And Not (IsEmpty(Cells(start_row +
num_row, "G"))))
num_row = num_row + 3
Wend
Dim end_row As Integer
end_row = num_row + start_row - 1
' Calculate Rate of Return
Dim m_r_j As Double
Dim m_r_m As Double
For r = start_row To end_row - 3 Step 1
old_ = Cells(r, "G")
new_ = Cells(r + 3, "G")
m_r_j = (new_ - old_) / old_
Cells(r + 3, "M").Value = m_r_j
Next
End Sub
Last edited by a moderator: