Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Row Above and Calculate Difference Between Dates Jazz Excel Programming 2 September 11th 09 03:11 PM
calculate difference between 2 dates nikko Excel Worksheet Functions 16 September 11th 08 11:15 AM
Calculate difference in dates Geo Excel Discussion (Misc queries) 11 August 12th 08 07:18 AM
How do I calculate the difference between 2 dates (m,d,y) ? ady_sandu Excel Worksheet Functions 8 September 29th 05 05:09 PM
Calculate Difference b/e 2 dates. scharee New Users to Excel 2 August 2nd 05 04:28 PM


All times are GMT +1. The time now is 07:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"