Macro to calculate billing schedule?

jmthompson

Well-known Member
Joined
Mar 31, 2008
Messages
966
Good afternoon,
I have just been passed a new VBA project and there is one component I would like help with.

Column J lists a start date
Column K lists an end date
Column N lists a dollar amount.
Columns P through the last column has headers of month-year in text form(for example May-08)

The user enters contract information in the spreadsheet including the above cells. What they want to automate is once the user enters the contract information on a given row, she runs a macro to determine the billing schedule by calculating how many months there are between the start and end dates, divide the dollar amount in column N by that number and then prompt the user to enter what month the first payment is due, once that is entered, the macro should place the payment amount in that column and all applicable subsequent columns.

For example,
Column J = 6/1/2008
Column K = 9/1/2008
Column N = 3,000
The macro should calculate 3 months, the monthly payment amount is $1000.
A starting month prompt appears and the user enters July-08. The macro then places 1,000 in the columns for July-08, August-08 and September-08.

Is such a thing possible?
 
Hi,

Paste this code to sheet1 code module.
Right click the sheet tab that has the data you want to change. Select "View Code"
Then paste.
The start date I'm assuming will be for the start date for the payment.
The code works after the user inputs a $ amount. This amount will be divide by 3 and then
the amounts should be placed in the correct months.



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Mycol As Integer
Dim cnt As Integer
Dim cell As Range
Dim MyStartdate As String
Dim Myamount As String, MysubAmt As String
Mycol = Target.Column
If Mycol = 14 Then '' column that the $ amount is in.
    Myamount = Cells(Target.Row, 14)
    MyStartdate = Cells(Target.Row, 10)
    For i = 1 To 3
    Mytime = DateSerial(Year(MyStartdate), Month(MyStartdate) + cnt, Day(MyStartdate))
    
        MysubAmt = Myamount / 3
        For Each cell In Range("P1:V1")
            If cell.Value = Mytime Then
            Application.ScreenUpdating = False
                Cells(Target.Row, cell.Column).Value = MysubAmt
                cnt = cnt + 1
                Application.ScreenUpdating = True
            End If
        Next cell
    Next i
End If

End Sub
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,861
Messages
6,121,969
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top