+ Reply to Thread
Results 1 to 3 of 3

macro loan loop

Hybrid 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

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro loan loop

    You need to explain what you require to be done. It will be good if you attach a sample file.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: macro loan loop

    Also,

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.

+ Reply to Thread

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