Results 1 to 3 of 3

macro loan loop

Threaded View

samz93 macro loan loop 03-08-2013, 12:10 PM
arlu1201 Re: macro loan loop 03-08-2013, 12:17 PM
arlu1201 Re: macro loan loop 03-08-2013, 12:17 PM
  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    26

    Exclamation macro loan loop

    hi im new to excel vba and im terribly stuck on something and was hoping somebody could help me
    I need to use looping to make a loan schedule table until the loan is cleared. The macro i have written (see below) doesnt run and it keeps coming up with error but i cant see where im going wrong. if anyone could please help!

    thanks in advance!



    Sub MACROE()
    
    Do
    Range("A19") = 1
    Dim z As Date
    z = Range("D9")
    If Range("D8") = Mid("monthly", 1, Len(Range("D8"))) Then
    Range("B19") = DateAdd("m", 1, z)
    ElseIf Range("D8") = Mid("quarterly", 1, Len(Range("D8"))) Then
    Range("B19") = DateAdd("q", 1, z)
    ElseIf Range("D8") = Mid("yearly", 1, Len(Range("D8"))) Then
    Range("B19") = DateAdd("yyyy", 1, z)
    End If
    
    Range("C19") = Range("D5")
    
    Range("D19") = re(Range("D6"), Range("D8"), Range("D7"), Range("D5"), Range("D11"), Range("D10"))
    
    Range("E19") = Range("D11")
    
    Range("F19") = Range("D19") + Range("E19")
    
    Range("G19") = Range("F19") - ((Range("C19") * istar(Range("D6"), Range("D8"))))
    
    Range("H19") = Range("F19") - Range("G19")
    
    Range("I19") = Range("C19") - Range("F19")
    
    Range("J19") = Range("H19")
    
    Exit Do
    
    
    Loop Until Cells(x, 9) = 0
    Do
    
    Cells(x, 1) = x - 18
    
    If Range("D8") = Mid("monthly", 1, Len(Range("D8"))) Then
    Range(x, 2) = DateAdd("m", 1, Range(x, 2))
    ElseIf Range("D8") = Mid("quarterly", 1, Len(Range("D8"))) Then
    Range(x, 2) = DateAdd("q", 1, Range(x, 2))
    ElseIf Range("D8") = Mid("yearly", 1, Len(Range("D8"))) Then
    Range(x, 2) = DateAdd("yyyy", 1, Range(x, 2))
    End If
    
    Cells(x, 3) = Cells(x - 1, 9)
    If Range("D10") = Mid("level", 1, Len(Range("D10"))) Then
    Cells(x, 4) = Application.WorksheetFunction.Min(Range("D" & x - 1), (Cells(x, 3) + Cells(x, 3) * istar(Range("D6"), Range("D8"))))
    ElseIf Range("D10") = Mid("decreasing", 1, Len(Range("D10"))) Then
    Cells(x, 4) = Application.WorksheetFunction.Min(Range("D" & x - 1), (Cells(x, 3) + Cells(x, 3) * istar(Range("D6"), Range("D8")) - (Cells(x - 1, 5) - Cells(11, 4))))
    ElseIf Range("D10") = Mid("increasing", 1, Len(Range("D10"))) Then
    Cells(x, 4) = Application.WorksheetFunction.Min(Range("D" & x - 1), (Cells(x, 3) + Cells(x, 3) * istar(Range("D6"), Range("D8")) - (Cells(x - 1, 5) + Cells(11, 4))))
    End If
    
    If (Cells(x, 4) = Cells(x - 1, 4)) Then
    If Range("D10") = Mid("decreasing", 1, Len(Range("D10"))) Then
    Cells(x, 5) = Cells(x - 1, 5) - Cells(11, 4)
    ElseIf Range("D10") = Mid("increasing", 1, Len(Range("D10"))) Then
    Cells(x, 5) = Cells(x - 1, 5) + Cells(11, 4)
    End If
    Else
    If Range("D10") = Mid("level", 1, Len(Range("D10"))) Then
    Cells(x, 5) = 0
    ElseIf Range("D10") = Mid("increasing", 1, Len(Range("D10"))) Then
    Cells(x, 5) = Cells(x - 1, 5) + Cells(11, 4)
    ElseIf Range("D10") = Mid("decreasing", 1, Len(Range("D10"))) Then
    Cells(x, 5) = Cells(x - 1, 5) - Cells(11, 4)
    End If
    
    Cells(x, 6) = Cells(x, 4) + Cells(x, 5)
    Cells(x, 7) = Cells(x, 6) - (Cells(x, 3) * istar(Range("D6"), Range("D8")))
    Cells(x, 8) = Cells(x, 3) * istar(Range("D6"), Range("D8"))
    Cells(x, 9) = Cells(x, 3) - Cells(x, 7)
    Cells(x, 10) = Cells(x - 1, 10) + Cells(x, 8)
    
    End If
    
    
    
    End Sub
    Last edited by arlu1201; 03-08-2013 at 12:16 PM. Reason: Use code tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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