VBA DDB Function (Syntax + Example)

Last Updated: June 22, 2023
puneet-gogia-excel-champs

- Written by Puneet

The VBA DDB function is listed under the financial category of VBA functions. When you use it in a VBA code, it can calculate depreciation by using the double declining balance method or you can supply the depreciation rate directly into the function. Learn more about the double declining balance method from here.

Syntax

DDB(Cost, Salvage, Life, Period, [Factor])

Arguments

  • Cost: The initial cost of the asset.
  • Salvage: The value of the asset at the end.
  • Life: The number of periods over which the asset is to be depreciated.
  • Period: The period for which you want to calculate the depreciation.
  • Factor: Rate of depreciation [This is an optional argument and if omitted VBA takes 2 by default].

Example

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

example-vba-ddb-function
Sub example_DDB()
Range("B6").Value = DDB(14500, 500, 10, 10)
End Sub

In the above code, we have used DBB to calculate the depreciation of the asset and it has returned 389 in the result.

Notes

  • With the double-declining balance method, depreciation is highest in the first period and decreases in successive periods.
  • VBA will return run-time error ‘5’ (invalid procedure call or argument) if the salvage value is less than zero, Life, Period, or [Factor] is equal or less than zero, or the period of depreciation is greater than the life of the asset.