Results 1 to 11 of 11

Function argument's cell adress

Threaded View

  1. #1
    Registered User
    Join Date
    08-26-2009
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    28

    Function argument's cell adress

    Hi all!

    I have an attached file and I am trying to build a VBA function to calculate total values. First row is "RollingTime" and for example if I am trying to calculate the "Total" value. For "RollingTime" = 2 it should be

    RollingTime(2)*Percentage(2)+RollingTime (1)*(1-Percentage(1))*Percentage(2)+RollingTime(0)*(1-Percentage(0)*(1-Percentage(1))*Percentage(2)

    Which is 109732508*0,3 + 1017508995*(1-0,2)*0,3+1587172158*(1-0,1)*(1-0,2)*0,3

    And here is the code I have tried to produce:

    Function Calls(Percentage As Double, Amount As Double, RollingTime As Integer) As Double
    
    Dim i As Integer, Previous As Double
    
    Previous = 0
    
    If RollingTime = 0 Then
        Calls = Percentage *Amount
        Exit Function
    End If
    
    
    For i = 1 To RollingTime
        
            
            Previous = Amount.Offset(0, -i).Value + Previous * (1 - CallProb.Offset(0,-i)) ^ i
           
            
            
    Next
    
    Calls = CallProb * CallAmount + Previous
    
        
        
    End Function

    The problem in the function is that I (of course) cannot use "Amount.Offset" or "CallProb.Offset". So how could I determine what are the cell adresses for those arguments? So if the RollingTime argument is "2", Amount.offset(0,-2).Value would be 1587172158.

    Hope I am not too confusing..

    -John
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1