David -
I thought so too- that maybe I am probably not making myself
clear enough. I apologize for the confusion. ** Practically,I would
use this macro to simplify a job responsibility --- If there was a
way, I would have e-mailed you the exact report. Please, let me
re-explain this in a more practical sense.
** I get a report in an Excel sheet which looks exactly like:
--------------------------------------------------------------
9/10/03
9/11/03 Let's call this set of 7 successive dates "Block 1".
9/12/03
9/13/03 ** Note:
9/14/03 By 7 successive dates, I mean if you count the dates
9/15/03 in this block (enclosed by lines) they are 7 in number.
9/16/03
---------------------------------------------------------------
9/10/03
9/11/03
9/12/03
9/13/03 Let's call this set of 7 dates "Block 2 "
9/14/03
9/15/03
9/16/03
------------------------------------------------------------
9/10/03
9/11/03
9/12/03
9/13/03 This one "Block 3"
9/14/03
9/15/03
9/16/03
------------------------------------------------------------
-- The report could contain any number of these "blocks".
* As you can see, each "Block" has two distinct properties:
** (1) The *number* of dates in each *Block* is 7.
** (2) The set of successive dates in each "Block" are the same dates,
regardless of what dates they may be.
-- I want a macro that will loop through the date column of each
"block" of cells. If the macro finds that in any "block" there are
missing dates then it should insert blank rows and update the dates.
** As an example-- Suppose there is a "Block 4" below "Block 3" in the
above illustration which looks like
------------------------------------------------------------
9/10/03
9/11/03
9/14/03 "Block 4"
9/15/03
9/16/03
------------------------------------------------------------
** We see that "Block 4 " has 5 number of dates instead of 7 number
of dates. Its dates column is missing 9/12/03 and 9/13/03. So, when
the macro loops through "Block 4", it will insert 2 blank rows between
9/11/03 and 9/14/03, then update the block with those two dates. That
way "Block 4" becomes like the below with 7 number of dates
------------------------------------------------------------
9/10/03
9/11/03
9/12/03----inserted row by macro
9/13/03---- inserted row by macro
9/14/03
9/15/03 "Corrected Block 4"
9/16/03
------------------------------------------------------------
**In the same way,the macro would "scan" through the date column of
all existing "Blocks" and for any missing dates, insert equivalent
number of rows and update the dates column.**
-- In the end, every "Block" would contain 7 number of dates. The
dates will still be the same serial number for every "Block".
-- On the other hand, if the macro loops through all the date columns
and finds that every "Block" contains 7 dates, of the same serial
number, then it won't have to do anything.
Please pardon me. I am not too good at making myself clear and I
hope the above illustration clarifies what I am trying to seek help
with. Again, sorry for any confusion and contradiction. Thanks.
Jay Dean
David McRitchie said:
Hi Jay,
Your directions are too confusing and probably contradictory.
This is what Cecil and I gave you where * is inserted row
that was previously missing. No dates before 2003-09-02
no dates after 2003-09-08 as per our understanding of seven
days, if you started on 2003-09-02
2003-09-02
2003-09-03
2003-09-04 *
2003-09-05 *
2003-09-06 *
2003-09-07 *
2003-09-08 *
2003-09-02 *
2003-09-03
2003-09-04
2003-09-05
2003-09-06 *
2003-09-07
2003-09-08 *
If you don't want duplicate dates as you had in your example and
it has nothing to do with seven then Myrna's example possibly.
Your example is flawed because you do not show or distinguish
what you have and what you want. Repeating the same directions
does not change anything. You must be very clear on what you
want.
Try to phrase things more directly, rather than placing negatives
at the end to change the whole meaning of what was just read.
Again it I ask, what is this for, it really does not seem to have
a practical purpose, except as possibly a homework assignment.
I would suggest that you take a try at modifying the coding that
has been supplied and post your own code, specify whether your
modified code worked or not. If it didn't what it is missing.
If you don't want to do that, at least specify exactly what you have
and what you want in a *short* example that demonstrates exactly
what you want without ambiguity.
Your new instructions are meaningless.
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages:
http://www.mvps.org/dmcritchie/excel/excel.htm
Jay Dean said:
IF Bob's first code can be modified to
(1) insert and correct dates for down the whole column as long as
there are dates (not just the first seven rows in the column) and
(2) work for ALL dates (not just dates up to the 7th)
It will BE EXACTLY what I am looking for. Thanks!
Jay Dean