Private Sub Worksheet_Change(ByVal Target As Range)
Dim sat As Long
Dim fark As Double
Dim toplamgun As Double, yil As Integer, ay As Integer, gun As Double
Dim c_Hucre As Range, D_Hucre As Range
Const biryil As Integer = 360
Const ikiyil As Integer = biryil * 2
Const birAy As Byte = 30
On Error Resume Next
If Not Intersect(Target, [C420]) Is Nothing Then
sat = Target.Row
Set c_Hucre = Cells(sat, "C")
Set D_Hucre = Cells(sat, "D")
toplamgun = Day(D_Hucre) + birAy * Month(D_Hucre) + biryil * Year(D_Hucre) - (Day(c_Hucre) + birAy * Month(c_Hucre) + biryil * Year(c_Hucre))
yil = Int(toplamgun / biryil)
ay = Int((toplamgun - Int(toplamgun / biryil) * biryil) / birAy)
gun = toplamgun - Int(toplamgun / biryil) * biryil - Int((toplamgun - Int(toplamgun / biryil) * biryil) / birAy) * birAy
Range(Cells(sat, "E"), Cells(sat, Columns.Count)).ClearContents
Cells(sat, "E").Value = toplamgun
Cells(sat, "F").Value = yil
Cells(sat, "G").Value = ay
Cells(sat, "H").Value = gun
Select Case toplamgun
Case Is < ikiyil
fark = (ikiyil - toplamgun)
Range("i" & sat).Value = ikiyil
Range("j" & sat).Value = 2 - Range("f" & sat)
Range("k" & sat).Value = Int((fark - Int(fark / biryil) * biryil) / birAy)
Range("L" & sat).Value = fark - Int(fark / biryil) * biryil - Int((fark - Int(fark / biryil) * biryil) / birAy) * birAy
Case Is >= ikiyil
fark = (toplamgun - ikiyil)
Range("i" & sat).Value = fark
Range("j" & sat).Value = Int(fark / biryil)
Range("k" & sat).Value = Int((fark - Int(fark / biryil) * biryil) / birAy)
Range("L" & sat).Value = fark - Int(fark / biryil) * biryil - Int((fark - Int(fark / biryil) * biryil) / birAy) * birAy
End Select
End If
Set c_Hucre = Nothing
Set D_Hucre = Nothing
End Sub
Doğru sonuç veriyormu emin değilim.