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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -