How to calculate depreciation on dimishing balance method using VBA Excel -
my code follows:
function depreciation(pcost currency, age double) dim cvalue currency dim dep double select case age case < 1 dep = pcost cvalue = pcost - dep depreciation = cvalue case < 2 dim cvalue1 currency depreciation = cvalue * 0.25 cvalue1 = cvalue - depreciation depreciation = cvalue1 case < 3 dim cvalue2 currency depreciation = cvalue1 * 0.25 cvalue2 = cvalue1 - depreciation depreciation = cvalue2 end select end function
assuming want amount after depriciation, try below:
option explicit function depreciation(pcost currency, age double) const depreciationrate currency = 0.25 dim cvalue currency, double cvalue = pcost = age until < 1 cvalue = cvalue * (1 - depreciationrate) 'debug.print age - + 1, cvalue ' uncomment see value of wach year = - 1 loop depreciation = cvalue end function
Comments
Post a Comment