Thread: Formula syntax
View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Joe User[_2_] Joe User[_2_] is offline
external usenet poster
 
Posts: 905
Default Formula syntax

I wrote:
=if(K3="", "",
if(left(K3)="4", if(M3="a", "CTA", "STD"),
if(M3="a", "STA", "Gil")))


Another alternative:

=LOOKUP(left(K3)&M3, {"","4a","4c","5a","5c"}, {"","CTA","STD","STA","Gil"})

Assumes that M3 appears blank when K3 appears blank.


----- original message -----

"Joe User" wrote:
"Dale G" wrote:
That statement is true. The letters used will only
be "a" Or "c" and the first number will always be
a 4 or 5.


Well, your original formula suggests that K3 might also appear blank. So
you might try:

=if(K3="", "",
if(left(K3)="4", if(M3="a", "CTA", "STD"),
if(M3="a", "STA", "Gil")))


----- original message -----

"Dale G" wrote:
Both formulas can be simplified if you said that M3 will only have
"a" or "c" when left(K3) is "4" or "5", and if left(K3) will ony be "4" or
"5".

That statement is true. The letters used will only be "a" Or "c" and the
first number
will always be a 4 or 5.



"Joe User" wrote:

"Dale G" wrote:
I'm trying to have cell C3 show CTA if the number
in K3 starts with a 4 and the letter in M3 is "a".
And if the number in K3 starts with a 4 and the
letter in M3 is "c" have C3 show STD.

Or if the number in K3 starts with a 5, and M3 is "a"
have C3 show STA, or if K3 starts with a 5 and M3 is
"c" then C3 would show Gil.

One way:

=if(left(K3)="4",
if(M3="a", "CTA", if(M3="c", "STD", "")),
if(left(K3)="5",
if(M3="a", "STA", if(M3="c", "Gil", "")), ""))

Alternative:

=if(left(K3)="4", if(M3="a", "CTA", if(M3="c", "STD", "")), "")
& if(left(K3)="5", if(M3="a", "STA", if(M3="c", "Gil", "")), "")

The alternative is less efficienct (infinitesimally), but it is more
extensible because it has less function nesting.

Note: Both formulas can be simplified if you said that M3 will only have
"a" or "c" when left(K3) is "4" or "5", and if left(K3) will ony be "4" or
"5".


----- original message -----

"Dale G" wrote:
Hi, I'm trying place a formula in cell C3.

IF(AND(K3="","",IF(LEFT(K3)="4",M3="a"),"CTA","STD "),IF(AND(K3="","",IF(LEFT(K3)="5",M3="a"),"STA"," Gil"))

I'm trying to have cell C3 show CTA if the number in K3 starts with a 4 and
the letter in M3 is "a". And if the number in K3 starts with a 4 and the
letter in M3 is "c"
have C3 show STD.

Or if the number in K3 starts with a 5, and M3 is "a" have C3 show STA, or
if K3 starts with a 5 and M3 is "c" then C3 would show Gil.

Any help is appreciated.