View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jay Dean Jay Dean is offline
external usenet poster
 
Posts: 154
Default INSERTING ROWS WITH A MACRO

Bob --
The code below does not seem to work. Maybe this will clarify the
code I need.If I have multiple successive seven dates like

9/15/2003
9/16/2003
9/17/2003
9/18/2003
9/19/2003
9/20/2003
9/21/2003
9/15/2003
9/16/2003
9/17/2003
9/18/2003
9/19/2003
9/20/2003
9/21/2003
9/15/2003
9/16/2003
9/17/2003
9/18/2003
9/19/2003
9/20/2003
9/21/2003

It goes way down the column. I need a Macro to loop through the entire
column. If it finds that any dates are missing, it should insert blank
rows for the missing dates.


"Bob Phillips" wrote in message ...
Jay,

Here's some code
Dim cRows As Long, i As Long

For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Day(Cells(i, "A").Value) 1 Then
If Cells(i, "A").Value < Cells(i - 1, "A").Value + 1 Then
Cells(i, "A").EntireRow.Insert
Cells(i, "A").Value = Cells(i + 1, "A").Value - 1
i = i + 1
End If
End If
Next i

You don't say what to say with dates greater than 7th, so I have ignored
that.

--

HTH

Bob Phillips

"Jay Dean" wrote in message
om...
I need a macro code for the following.
In Excel, my worksheet contains a colum of dates
grouped in a repetition/successions of 7 dates like

9/1/2003 pen School
9/2/2003 paper .
9/3/2003 book .
9/4/2003 toy .
9/5/2003 drink .
9/6/2003 snack .
9/7/2003 .. .
9/1/2003 shoes Camp
9/2/2003 hat .
9/3/2003 ............the group of repeated
7 dates continues down the column. I would like a code
for a macro that will check the date column for as
far down the column as possible to make sure that for
EACH block of 7 days no number of date rows are
missing.

For Example: The macro would check that from
9/3/2003 the next row down contains 9/4/2003, not
9/7/2003
If any number of dates are missing the macro should
insert blank rows and update the date column for the
inserted blank rows--that's it!

That is, in the Example above if 9/7/2003 is the next
date under 9/3/2003, then the macro should insert 3
blank rows next below 9/3/2003 and update them as
9/4/2003
9/5/2003
9/6/2003,
then the 9/7/2003.

Please help. Thanks!

Jay Dean