Insert Row and calculate difference between two dates
just add one line
from
Range("A" & lngRow) = Date - Range("G" & lngRow + 1)
to
Range("A" & lngRow) = Date - Range("G" & lngRow + 1)
Range("D" & lngRow) = Date - Range("H" & lngRow + 1)
"Jazz" wrote:
I am looking to insert a row above each row with contents starting in Row 2.
Minus the date in Column C for each row with contents from todays date and
put the difference in Column A the empty row above. Here is what I am
starting with.
Dim lngRow As Long, blnInsert As Boolean
lngRow = 2
Do While lngRow <= Cells(Rows.Count, "G").End(xlUp).Row
blnInsert = Not blnInsert
If blnInsert Then
Rows(lngRow).Insert
Range("A" & lngRow) = Date - Range("G" & lngRow + 1)
End If
lngRow = lngRow + 1
Loop
I would like to add to this code so that it will also minus the date in
Column H for each row with contents from todays date and put the difference
in Column D the empty row above. Can you help?
|