can you please advise how to loop my code through all populated rows (based on row D)? I need to subtract d2 from ad2, d3 from ad3 and so on and put the results in ae column (offset I guess).
Ideally, avoiding entering formulas in ae and instead using Application.WorksheetFunction.Value=Total
?
Sub valuedifference()
Dim Total As Double
Dim TimeX As Date
Dim TimeY As Date
With ThisWorkbook.Sheets("Test1")
TimeX = CDate(Range("d2").Value)
TimeY = CDate(Range("ad2").Value)
Total = TimeValue(TimeY) - TimeValue(TimeX)
Range("ag2").Value = Abs(Total * 24)
Range("ah2").Value = Abs(Total * 1440)
End With
End Sub