VBA SLN Function

HomeVBA Functions LIST (Category Wise)How to use the VBA SLN Function (Syntax + Example)

What is VBA SLN Function

The VBA SLN function is listed under the financial category of VBA functions. When you use it in a VBA code, it calculates the straight line depreciation of an asset for a single period. Learn more about this calculation from here.

how to use it

To use VBA's SLN function you need to understand its syntax and arguments:


SLN(Cost, Salvage, Life)


  • Cost: The initial cost of the asset you are calculating depreciation for.
  • Salvage: The ending value of the asset after its useful life.
  • Life: The number of periods over which the asset is to be depreciated.

Example to use SLN Function in VBA

To practically understand how to use VBA SLN function, you need to go through the below example where we have written a vba code by using it:

Sub example_SLN()
Range("A7").Value = SLN(15000, 1200, 8)
End Sub

In the above code, we have used the SLN to calculate the straight-line depreciation using the cost, salvage, and life period and it has returned 1725 in the result as per the inputs specified.


Below are some important points which you need to take care while using SLN function in VBA.

  • If the life supplied is equal to zero then VBA will return a run-time 5 error.

Related Functions

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.