I have a loan amortization schedule that creates the amortization schedule depending on the periods, how can I clear the range, before running the loan amortization again? For example, if I run it for a 10 year period, then run it for a 5 year period, years 6-10 still show up because they haven't been cleared.
Here is my code:
outRow = 3
With Sheets("Loan")
lCol = .Cells(3, .Columns.Count).End(xlToLeft).Column
lrow = .Cells(.Rows.Count, lCol).End(xlUp).Row
End With
Sheets("Loan").Range(Cells(outRow, 5), Cells(Lastrow, lastCol)).ClearContents
If you add "+1" after .Row you will keep the headings in case the file is empty. [if it is empty and the code runs without "+1" it will erase the headings]
The above will work for clearing all cells in column A. If you need it for multiple columns then change the second
A
in theRange(A2:A
line.Try this, takes the UsedRange of the worksheet offset 1 row down to and clears contents