I have logic in place, but don't know how to execute / code it in Excel. Logic below:
In the office, I need to find out the value of many old articles based on their purchase price and age. I do not want to use VDB or other built-in functions.
In my table:
A1 = "Table" (Name of the article)
B1 = "01/01/2005" (Date of purchase in MM/DD/YYYY format)
C1 = "1000" (Purchase value)
D1 = "=DATEDIF(B1,TODAY(),"Y")" (Gives the age of article in years)
E1 = "20" (Percentage depreciation for first year, which varies based on article)
F1 = "=C1*10%" '(Depreciated value should not be less than 10% of purchase value)
Now, in G1, I want to calculate the depreciation of the article " A1" with the purchase price " C1" for " D1" the number of years, @flat " E1"% for the first year and 10% for subsequent years.
H1 = "=C1-G1" (Value of the article after depreciation)
I1 = "=IF(H1<=F1,F1,H1)"
Please help me with a macro or formula for a loop and find out the meaning G1.
Also, I want to apply this to the "n" number of rows, since there is an "n" number of articles.
EDIT
@assylias SO, .
30 , , , , . :
Sub DepVal()
'
' DepVal Macro
' Macro by Prashanth JC
'
' Keyboard Shortcut: Ctrl+d
'
fYear = 0
dVal = 0
tYear = ActiveCell.Offset(0, -3)
purVal = ActiveCell.Offset(0, -4)
depFirst = ActiveCell.Offset(0, -2)
depOther = 10
If tYear >= 1 Then
Do
If fYear = 0 Then
dVal = purVal - (purVal * depFirst) / 100
Else
dVal = dVal - (dVal * depOther) / 100
End If
fYear = fYear + 1
Loop Until fYear = tYear
ActiveCell.Value = dVal
Else
ActiveCell.Value = purVal
End If
End Sub
, G1 . !
, SO assylias!