I've found some information online to help our finance department with expense amortization, however rather than having the amortization happen over days within the month (calculating the dailyrate * days in month), I'd simply like for this same functionality to work at a month scale, where the amount is the same regardless of the days in the month.
The click button interface and ability to blow out the months in the results field is ideal, and I have tried to make some modifications to the macro in order to have it simply calculate based off the months within the start and end dates, but it is beyond me. Here is a link to the document https://www.dropbox.com/s/dva7pn1t5qulzvz/test.xlsm?dl=0
password for vba is 1234
Any help is greatly appreciated!
The click button interface and ability to blow out the months in the results field is ideal, and I have tried to make some modifications to the macro in order to have it simply calculate based off the months within the start and end dates, but it is beyond me. Here is a link to the document https://www.dropbox.com/s/dva7pn1t5qulzvz/test.xlsm?dl=0
password for vba is 1234
Any help is greatly appreciated!
Code:
Sub Button1_Click()
Dim cellNum, prepLife, prepStart, prepEnd, outCol, prepAmt, prepAmort, PrepBal, amtDecl, firstAmort, dailyRate, starterDate As Variant
Dim monthDate, JEStart, JEEnd As Date
Application.ScreenUpdating = False
Range("B16:XFD27").ClearContents
Range("B16:XFD27").Interior.ColorIndex = 2
prepLife = Range("preplife")
firstAmort = Range("firstamort")
prepAmt = Range("prepaidamount")
prepStart = Range("startdate")
JEStart = Range("JEStart2")
JEEnd = Range("JEEnd2")
totaldays = Range("totaldays")
starterDate = Range("StarterDate")
prepAmort = prepAmt / prepLife
dailyRate = prepAmt / totaldays
startamt = Range("startamort")
monthDate = prepStart - Day(prepStart) + 1
daysinMonth = Day(DateSerial(Year(monthDate), Month(monthDate) + 1, 0)) - starterDate + 1
amtDecl = prepAmt - dailyRate * daysinMonth
Cells(16, 2).Value = monthDate
Cells(17, 2).Value = prepAmt
Cells(18, 2).Value = dailyRate * daysinMonth
Cells(19, 2).Value = amtDecl
Cells(22, 2).Value = dailyRate * daysinMonth
Cells(23, 2).Value = -dailyRate * daysinMonth
totamort = dailyRate * daysinMonth
If monthDate >= JEStart And monthDate <= JEEnd Then
Cells(16, 2).Interior.ColorIndex = 24
Cells(17, 2).Interior.ColorIndex = 24
Cells(18, 2).Interior.ColorIndex = 24
Cells(19, 2).Interior.ColorIndex = 24
Cells(22, 2).Interior.ColorIndex = 24
Cells(23, 2).Interior.ColorIndex = 24
Else
Cells(16, 2).Interior.ColorIndex = 2
Cells(17, 2).Interior.ColorIndex = 2
Cells(18, 2).Interior.ColorIndex = 2
Cells(19, 2).Interior.ColorIndex = 2
Cells(22, 2).Interior.ColorIndex = 2
Cells(23, 2).Interior.ColorIndex = 2
End If
outCol = 0
Range("A21") = "Journal Entry"
For cellNum = 3 To (prepLife + 1)
monthDate = DateAdd("m", 1, monthDate)
daysinMonth = Day(DateSerial(Year(monthDate), Month(monthDate) + 1, 0))
declAmt = daysinMonth * dailyRate
Cells(16, outCol + cellNum).Value = monthDate
Cells(17, outCol + cellNum).Value = amtDecl
Cells(18, outCol + cellNum).Value = declAmt
Cells(19, outCol + cellNum).Value = amtDecl - declAmt
Cells(22, outCol + cellNum).Value = declAmt
Cells(23, outCol + cellNum).Value = -declAmt
If monthDate >= JEStart And monthDate <= JEEnd Then
Cells(16, outCol + cellNum).Interior.ColorIndex = 24
Cells(17, outCol + cellNum).Interior.ColorIndex = 24
Cells(18, outCol + cellNum).Interior.ColorIndex = 24
Cells(19, outCol + cellNum).Interior.ColorIndex = 24
Cells(22, outCol + cellNum).Interior.ColorIndex = 24
Cells(23, outCol + cellNum).Interior.ColorIndex = 24
Else
Cells(16, outCol + cellNum).Interior.ColorIndex = 2
Cells(17, outCol + cellNum).Interior.ColorIndex = 2
Cells(18, outCol + cellNum).Interior.ColorIndex = 2
Cells(19, outCol + cellNum).Interior.ColorIndex = 2
Cells(22, outCol + cellNum).Interior.ColorIndex = 2
Cells(23, outCol + cellNum).Interior.ColorIndex = 2
End If
startamt = amtDecl - declAmt
amtDecl = startamt
totamort = totamort + declAmt
Next cellNum
monthDate = DateAdd("m", 1, monthDate)
Cells(16, outCol + cellNum).Value = monthDate
Cells(17, outCol + cellNum).Value = startamt
Cells(18, outCol + cellNum).Value = startamt
Cells(19, outCol + cellNum).Value = 0
Cells(22, outCol + cellNum).Value = startamt
Cells(23, outCol + cellNum).Value = -startamt
If monthDate >= JEStart And monthDate <= JEEnd Then
Cells(16, outCol + cellNum).Interior.ColorIndex = 24
Cells(17, outCol + cellNum).Interior.ColorIndex = 24
Cells(18, outCol + cellNum).Interior.ColorIndex = 24
Cells(19, outCol + cellNum).Interior.ColorIndex = 24
Cells(22, outCol + cellNum).Interior.ColorIndex = 24
Cells(23, outCol + cellNum).Interior.ColorIndex = 24
Else
Cells(16, outCol + cellNum).Interior.ColorIndex = 2
Cells(17, outCol + cellNum).Interior.ColorIndex = 2
Cells(18, outCol + cellNum).Interior.ColorIndex = 2
Cells(19, outCol + cellNum).Interior.ColorIndex = 2
Cells(22, outCol + cellNum).Interior.ColorIndex = 2
Cells(23, outCol + cellNum).Interior.ColorIndex = 2
End If
Application.ScreenUpdating = True
End Sub