Reputation: 105
I have column K with a bunch of dates and I want to get the number of days between K's date and today's date inserted in column O.
My code for the first row is:
Range("O2").Value = Date - Range("K2").Value
How can I repeat this code for the rest of the column? Also, keep in mind that the length of populated cells in column K is dynamic and always changing.
Thanks to all that can help in advance!
Upvotes: 0
Views: 143
Reputation: 26
Range("O2").AutoFill Range("O2:O" & Cells(Rows.Count, "K").End(xlUp).Row)
That is if you have the formula already in cell O2.
Upvotes: 0
Reputation:
before:
Sub Main()
Dim i As Long
For i = 1 To Range("K" & Rows.Count).End(xlUp).Row
Range("O" & i) = DateDiff("d", Now, Range("K" & i))
Next i
End Sub
after:
Upvotes: 1