Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Row and calculate difference between two dates
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Row and calculate difference between two dates
Wow. Great. This is what I was looking for. Thank you.
"Joel" wrote: 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Insert Row Above and Calculate Difference Between Dates | Excel Programming | |||
calculate difference between 2 dates | Excel Worksheet Functions | |||
Calculate difference in dates | Excel Discussion (Misc queries) | |||
How do I calculate the difference between 2 dates (m,d,y) ? | Excel Worksheet Functions | |||
Calculate Difference b/e 2 dates. | New Users to Excel |