Consulting

Results 1 to 3 of 3

Thread: Help with Excel Macro to computer investment return

  1. #1
    VBAX Newbie
    Joined
    Mar 2021
    Posts
    1
    Location

    Help with Excel Macro to computer investment return

    Beginning
    Claim Payments
    Expenses
    Return Premium
    Profit Share
    Taxes
    End of Period
    Avg Annual Balance
    Interest
    Investment Return

    I have the above and want to compute the investment return which is intereest x avg annual balance.

    Wrote the following UDF:

    Sub udf_investreturn()


    End Sub
    Function investreturn(rate, beginning)
    
    
    For i = 1 To 10
        average_bal = beginning + ending / 2
        investreturn = average_bal * rate
        Next i
    End Function

    But my investment return is slighly off. Why?
    Last edited by SamT; 03-14-2021 at 05:24 PM.

  2. #2
    VBAX Newbie
    Joined
    May 2023
    Posts
    1
    Location
    I noticed that this thread is a couple of years old, but no worries, I'm still here to help you out with your Excel macro conundrum! First, in your ""For"" loop, I see that you're iterating from 1 to 10, but it seems like you're not actually using the loop index ""i"" within the loop. Make sure to incorporate the loop index into your calculations to ensure you're considering all the relevant values. Additionally, it looks like you're missing the ""ending"" value in your formula for calculating the average balance. You'll need to include that value in the calculation.
    Last edited by Aussiebear; 05-23-2023 at 06:12 AM. Reason: Removed link

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    @JackPaul, Yes the thread is getting a little longer in the tooth than we would prefer.

    The result may well be because the initial formula was missing some brackets

    Function investreturn(rate, beginning)
    For i = 1 To 10
        average_bal = (beginning + ending) / 2
        investreturn = average_bal * rate
        Next i
    End Function
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •