View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default Copying rows down into cells across until row=false ?

With your sample data in column A and your formula in column B, put
this formula in C1 and copy it down:

=IF(B1,COUNTIF(B$1:B1,TRUE),"")

It will give you a sequential count of the TRUEs in column B (i.e.
identify where the new columns (parents) should be).

Then you can put this formula in D1 and copy it down:

=IF(ISNA(MATCH(ROW(A1),C:C,0)),"",INDEX(A:A,MATCH( ROW(A1),C:C,0)))

This will produce your new headings for each row (parents). Then you
can put this formula in E1:

=IF(OR(D1="",INDEX($B:
$B,ROW(A1)+COLUMN(A1))),"",IF(D2<"",IF(MATCH($D1, $A:$A,
0)=MATCH($D2,$A:$A,0)-1,"",INDEX($A:$A,MATCH(ROW(A1),$C:$C,
0)+COLUMN(A1))),INDEX($A:$A,MATCH(ROW(A1),$C:$C,0) +COLUMN(A1))))

This can be copied across to suit the number of child cells you are
likely to encounter (5 is enough for your sample data), then those
cells can be copied down as far as you need them. You will end up with
something like this:

COW TRUE 1 COW
SHEEP TRUE 2 SHEEP Jim Bob Stu
Jim FALSE RHINO Dave Ollie
Bob FALSE
Stu FALSE
RHINO TRUE 3
Dave FALSE
Ollie FALSE

Then you can fix the values in D1 across and down and then concatenate
your child cells. You can delete the first 3 columns.

Hope this helps.

Pete





On Mar 26, 10:56*pm, jonski wrote:
Sorry about the title, let me explain in more detail:

In row A, I have various listings. The title is always in caps, the user is
always in mixed case.

For example:

COW
SHEEP
Jim
Bob
Stu
RHINO
Dave
Ollie

So, no-one is interested in COWS but Jim, Bob and Stu like SHEEP. And what I
need to end up with is:

COW
SHEEP | Jim, Bob and Stu
RHINO | Dave and Ollie

You get the picture. It doesn't matter if the readers names go into one cell
each, I can concatenate them later.

Now, what I've worked out is that I can put a TRUE or a FALSE in the next
column along, with:
=IF(AND(LEN(A1)1,EXACT(A1, UPPER(A1))),TRUE,FALSE)

So I've got

Code:
COW * | TRUE
SHEEP | TRUE
Jim * | FALSE
Bob * | FALSE
Now, what I HAD planned on doing was a formula which would test if the cell
to the right of A1 said true or false, then concatenate the contents of the
cell below the contents of A1 in the most recent TRUE cell, then concatenate
that plus the next on and the next one until we get another TRUE. But of
course, the cell value changes too.

So I'm clearly out of my depth here! I just showed that to prove that I have
at least tried and thought about it,