2017-07-26 7 views
0

Mein Code ist wie folgt:Wie Abschreibungen auf dimishing Balance-Methode berechnen VBA mit Excel

Function Depreciation(pCost As Currency, Age As Double) 

    Dim cValue As Currency 
    Dim Dep As Double 

    Select Case Age 
     Case Is < 1 
      Dep = pCost 
      cValue = pCost - Dep 
      Depreciation = cValue 

     Case Is < 2 
      Dim cValue1 As Currency 
      Depreciation = cValue * 0.25 
      cValue1 = cValue - Depreciation 
      Depreciation = cValue1 

     Case Is < 3 
      Dim cValue2 As Currency 
      Depreciation = cValue1 * 0.25 
      cValue2 = cValue1 - Depreciation 
      Depreciation = cValue2 
    End Select 

End Function 

Antwort

0

Angenommen, Sie den Betrag nach Wertverminderung wollen, versuchen Sie unter:

Option Explicit 

Function Depreciation(pCost As Currency, Age As Double) 
    Const DepreciationRate As Currency = 0.25 
    Dim cValue As Currency, i As Double 

    cValue = pCost 
    i = Age 
    Do Until i < 1 
     cValue = cValue * (1 - DepreciationRate) 
     'Debug.Print Age - i + 1, cValue ' Uncomment to see value of wach year 
     i = i - 1 
    Loop 
    Depreciation = cValue 
End Function