elsuji
12-23-2019, 10:14 AM
Dear Team,
I am having dates in Worksheet Sheet1 column D. I want to subtract Todays date from a date in column D and update on Column L.
For that i am trying the following code. But it is not working
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow As Long, i As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
For i = 2 To LastRow
.Range("L" & i).Value = Date - Range("D" & i).Value
Next i
End With
End Sub
Can any one tell me what is the mistake on above code
I am having dates in Worksheet Sheet1 column D. I want to subtract Todays date from a date in column D and update on Column L.
For that i am trying the following code. But it is not working
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim LastRow As Long, i As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
For i = 2 To LastRow
.Range("L" & i).Value = Date - Range("D" & i).Value
Next i
End With
End Sub
Can any one tell me what is the mistake on above code