Hi there !
I recently had some problems with an excel macro which calculates the digressive depreciation of an asset.It might be a problem with the repetitive structures. If you could help me in this problem i would be very grateful ! Thank you!
Here is the VBA Code behind the macro:
Private Sub CommandButton2_Click()
Dim i As Variant
Dim j As Variant
Dim s As Variant
Dim t As Variant
Dim g As Variant
Dim n, o, p As Variant
Dim q As Date
Dim f As Variant
Dim AN, N0 As Variant
Dim w, w2 As Variant
Dim N1, N2 As Variant
Dim h, k, S40 As Variant
Dim S01 As String
Dim m, tt As Variant
Dim val02, zz, AS1, as2, zz2 As Variant
Dim nn1, pp, pp02, val03 As Variant
Dim iii, jj5 As Integer
Dim rez, rest As Variant
Dim Max22 As Variant
Dim gg01, gg02, mm, ll, nr12, op1 As Variant
Dim az, ttt As Integer
Dim abc As Variant
Dim jj As Integer
t = 65
i = 45
w = 1
Do Until i > t
n = Sheets("AMORTIZARE").Cells(i, 3) 'val de intrare a activului
m = Sheets("AMORTIZARE").Cells(i, 4) 'durata normala de functionare
q = Sheets("AMORTIZARE").Cells(i, 5) 'cota anuala de amortizare
o = Sheets("AMORTIZARE").Cells(i, 6) 'cota anuala de amortizare degresiva
zz = n
jj = 2
Do Until (val02 * (o / 100) <= val02 / (m + 1) - jj) 'And (jj < m + 1)
Sheets("SA").Cells(i, jj) = zz * o / 100
val02 = zz - Sheets("SA").Cells(i, jj)
zz = val02
jj = jj + 1
az = m + 1 - jj
Loop
abc = val02 * (o / 100)
For ttt = az To m + 1
Sheets("SA").Cells(i, ttt) = abc
Next
i = i + 1
Loop
Max22 = 0
Sheets("SA").Select
Sheets("SA").Cells(44, 1) = "Nr crt \ An"
Sheets("SA").Select
For gg01 = 45 To 64
mm = Sheets("AMORTIZARE").Cells(gg01, 4)
If Max22 < mm Then
Max22 = mm
End If
Next
ll = 1
For gg02 = 2 To Max22 + 1
Sheets("SA").Cells(44, gg02) = ("An " & ll)
ll = ll + 1
Next
nr12 = 1
For op1 = 45 To 64
If Sheets("AMORTIZARE").Cells(op1, 3) <> 0 Then
Sheets("SA").Cells(op1, 1) = nr12
nr12 = nr12 + 1
End If
Next
End Sub
And here is a bunch of useful links for the method of calculation:
http://www.assetaide.com/depreciation/calculation.html
http://my.opera.com/BangNgo/blog/dep...-methods-in-ax
Bookmarks