Amortization macro help

joles

New Member
Joined
Feb 7, 2019
Messages
8
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!

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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Any thoughts on whether or not it would be easier to just write a new macro than try to re-purpose this one?
 
Upvote 0

Forum statistics

Threads
1,213,501
Messages
6,114,010
Members
448,543
Latest member
MartinLarkin

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