G
Guy Lydig
I have a column of first names that has some blank cells, some with 1 name,
and some with 2 names. I inserted another column and want to have only
initials but if the first or second name begin with "Ch" or "Sh", I want the
"Ch" or "Sh" as the initial.
My function takes care of:
Blank cell
One name and the first two letters are Ch or Sh
One name and the first two letter are NOT Ch or Sh
Two names and the first and second names both begin with Sh or Ch
Two names and the first begins with Ch or Sh but not the second
Here's where the problem begins:
There are TWO other possibilities: the second name begins with Ch or Sh but
not the first OR there are two names and neither begins with Ch or Sh.
If I pretend there's only ONE other possibility (and put the last bit in the
If False part of the If function) all is well except that either I will have
"Ben Bob" as "B. Bo." OR "Ben Charles" as "B. C." depending on how I write
the last piece.
I should really be able to add one more piece to the formula to fix this but
every time I do, the formula sticks. Is there a limitation on the number of
Find, Mid, etc. functions?
Here's the formula I used (which ignores the case of only the 2nd of two
names beginning with "Ch" or "Sh"):
=IF(ISBLANK(B2),"",IF(AND(ISERROR(FIND("
",B2)),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&".",IF(ISERROR(FIND("
",B2)),LEFT(B2,1)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch"),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,2)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&". "&MID(B2,FIND("
",B2)+1,1)&".",LEFT(B2,1)&". "&MID(B2,FIND(" ",B2)+1,1)&".")))))
I tried to amend it to:
=IF(ISBLANK(B2),"",IF(AND(ISERROR(FIND("
",B2)),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&".",IF(ISERROR(FIND("
",B2)),LEFT(B2,1)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch"),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,2)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&". "&MID(B2,FIND("
",B2)+1,1)&".",IF(AND(FIND(" ",B2),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,1)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",LEFT(B2,1)&". "&MID(B2,FIND("
",B2)+1,1)&".")))))
but it's hanging on MID after the last OR.
I'm stumped. Any ideas why I can't fix this one glitch?
I'd appreciate any assistance. (I hate to admit defeat and ask but....)
Sorry for the length of this post.
TIA
Guy
and some with 2 names. I inserted another column and want to have only
initials but if the first or second name begin with "Ch" or "Sh", I want the
"Ch" or "Sh" as the initial.
My function takes care of:
Blank cell
One name and the first two letters are Ch or Sh
One name and the first two letter are NOT Ch or Sh
Two names and the first and second names both begin with Sh or Ch
Two names and the first begins with Ch or Sh but not the second
Here's where the problem begins:
There are TWO other possibilities: the second name begins with Ch or Sh but
not the first OR there are two names and neither begins with Ch or Sh.
If I pretend there's only ONE other possibility (and put the last bit in the
If False part of the If function) all is well except that either I will have
"Ben Bob" as "B. Bo." OR "Ben Charles" as "B. C." depending on how I write
the last piece.
I should really be able to add one more piece to the formula to fix this but
every time I do, the formula sticks. Is there a limitation on the number of
Find, Mid, etc. functions?
Here's the formula I used (which ignores the case of only the 2nd of two
names beginning with "Ch" or "Sh"):
=IF(ISBLANK(B2),"",IF(AND(ISERROR(FIND("
",B2)),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&".",IF(ISERROR(FIND("
",B2)),LEFT(B2,1)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch"),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,2)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&". "&MID(B2,FIND("
",B2)+1,1)&".",LEFT(B2,1)&". "&MID(B2,FIND(" ",B2)+1,1)&".")))))
I tried to amend it to:
=IF(ISBLANK(B2),"",IF(AND(ISERROR(FIND("
",B2)),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&".",IF(ISERROR(FIND("
",B2)),LEFT(B2,1)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch"),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,2)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",IF(AND(FIND("
",B2),OR(LEFT(B2,2)="Sh",LEFT(B2,2)="Ch")),LEFT(B2,2)&". "&MID(B2,FIND("
",B2)+1,1)&".",IF(AND(FIND(" ",B2),OR((MID(B2,FIND("
",B2)+1,2)="Ch"),MID(B2,FIND(" ",B2)+1,2)="Sh")),LEFT(B2,1)&".
"&MID(B2,FIND(" ",B2)+1,2)&".",LEFT(B2,1)&". "&MID(B2,FIND("
",B2)+1,1)&".")))))
but it's hanging on MID after the last OR.
I'm stumped. Any ideas why I can't fix this one glitch?
I'd appreciate any assistance. (I hate to admit defeat and ask but....)
Sorry for the length of this post.
TIA
Guy