Isolating string combinations

D

Demosthenes

This is a further iteration of a problem I've been working on and posted
earlier under the subject: "Question for Mr. T. Valko." The question is now
up for general consideration.

Say you have the following data:

AB
CD
CD
CE
CD
CF
AG
CD
CD
AB
CD
AB
CD
AB
CD
CF
CG
CE
CW

Which can be in one or two columns. I'm trying to analyze the makeup of the
"CX" occurrences (i.e., whether they are CD, CF, CG, etc), but ONLY IN CHAINS
longer than 4 occurrences (i.e., 4 C's in a row or longer). I could do this
if only I could figure out a way to create a helper column that is composed
of just these instances that I'm considering. So my question is: How do I
create a helper column that is composed of only the chains of 4 or longer?
Output for the above would be:

AB
CD
CD
CE
CD
CF

AB
CD
CF
CG
CE
CW

Does anyone have any thoughts on an easy way to do this?
 
S

Sam Wilson

Hi,

You can do it with two helper columns. I'm assuming your column starts from
A2:

In B2 use the following and copy down
=IF(LEFT(A2,1) = LEFT(A1,1),B1,ROW())

In C2 use the following and copy down
=IF(COUNTIF(B:B,B2)>3,A2,IF(COUNTIF(B:B,B3)>4,A2,""))

Column C is then your helper column.

Sam
 
B

Bernd P

Hello Sam,

Your formula is not working. Copy down the AG value into A9 and A10,
for example.

My suggestion consists of two helper columns and one resulting column:
I assume data starts from row 2 and row 1 contains titles in all
columns (text). [If row 1 contains empty cells output in column D
starts from row 3]
Enter into B2:
=IF(LEFT(A2,1)="C",(B1>0)*(B1+1),--(SUMPRODUCT(--(LEFT(A3:A6,1)="C"))
=4))
Enter into C2:
=(B2>0)*(MAX(C$1:C1)+1+(C1=0))
Enter into D2:
=IF(ISERROR(MATCH(ROW()-1,C:C,0)),"",INDEX(A:A,MATCH(ROW()-1,C:C,0)))
and now copy C2:D2 down as far as necessary.

Regards,
Bernd
 
D

Demosthenes

Bernd,

seems to work! thanks for your help. i think i was trying to make it too
complicated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top