Hello,
I am trying to create a macro which calculates the annualized return from a series of monthly returns. The macro should work as a function which asks the user to select the data to annualize and then outputs the return in the selected cell.
I believe I am close with the code below, however; I receive the error "unable to set the ForumulaArray Property of the range class" in the last step.
Sub Monthly_Annualized_Returns()
UserRange = Application.InputBox(Prompt:="Please Select Range", Title:="Range Select", Type:=64)
Dim x As Integer
x = UBound(UserRange)
Range("a1").Select
Selection.FormulaArray = _
"=(PRODUCT(R[-x]C:R[-1]C/100+1)^(12/COUNT(R[-x]C:R[-1]C))-1)*100"
End Sub
I am trying to create a macro which calculates the annualized return from a series of monthly returns. The macro should work as a function which asks the user to select the data to annualize and then outputs the return in the selected cell.
I believe I am close with the code below, however; I receive the error "unable to set the ForumulaArray Property of the range class" in the last step.
Sub Monthly_Annualized_Returns()
UserRange = Application.InputBox(Prompt:="Please Select Range", Title:="Range Select", Type:=64)
Dim x As Integer
x = UBound(UserRange)
Range("a1").Select
Selection.FormulaArray = _
"=(PRODUCT(R[-x]C:R[-1]C/100+1)^(12/COUNT(R[-x]C:R[-1]C))-1)*100"
End Sub