I've a code that does some calculations and changes to cells when specific row changes are detected. Here is the Code:
The problem is that I want to use that code in multiple areas when certain conditions are met. Currently I've that code pasted 4 times and it works, but creates redundancy. I want to create a (Sub/Function) to have this code and call it whenever the conditions are met. For example:
I tried to create a sub and call it but nothing changes, it doesn't call the sub at all.
Many Thanks!.
VBA Code:
Target.Formula = "=IF(" & CLng(Target.Value) & " < TODAY()," & _
"DATEDIF(" & CLng(Target.Value) & ",TODAY(),""d"") & "" Day(s) Ago""," & _
"DATEDIF(TODAY()," & CLng(Target.Value) & ",""d"") & "" Day(s) Ahead"")"
VBA Code:
Private Sub Calculate_Date(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("L:L")) Is Nothing Then
With ActiveWorkbook.Worksheets("Interested")
Application.EnableEvents = False
>>> Call The Code Here <<<
Application.EnableEvents = True
End With
End If
Many Thanks!.