Insert Row and calculate difference between two dates

J

Jazz

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 today’s date and put the difference
in Column D the empty row above. Can you help?
 
J

Joel

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top