Text in Formula

J

JimS

I have this formula:

=IF(D13="","",IF(C13=D13,"",IF(C13<0,D13-C13)))

The problem is that sometimes C13 and/or D13 will be text instead of a
number. The text might say E or PK which is actually the same as
zero.

I can't figure out a way to rewrite the formula to allow for this.
 
B

Bernard Liengme

Try
=IF(and(ISNUMERIC(D13),ISNUMERIC(C13)),IF(C13<0,D13-C13,""),"")
best wishes
 
H

Harlan Grove

JimS said:
=IF(D13="","",IF(C13=D13,"",IF(C13<0,D13-C13)))

The problem is that sometimes C13 and/or D13 will be text instead of a
number.  The text might say E or PK which is actually the same as
zero.
....

More alternatives. If any text should be treated as 0,

=IF(OR(D13="",C13=D13),"",N(D13)-N(C13))

If only certain text strings should be treated as 0 while others
should throw errors,

=IF(OR(D13="",C13=D13),"",IF(COUNT(MATCH(D13,{"E";"PK"},0)),0,D13)-
IF(COUNT(MATCH(C13,{"E";"PK"},0)),0,C13))
 
S

ShaneDevenshire

Hi,

This seems to do what you want:

=IF(OR(D13="",C13=D13,N(C13)>=0),"",N(D13)-C13)
 
J

JimS

Thanks to all. I will look at all of these suggestions. I have one
question. What is "N" in the formula below?

Thanks again
 
J

JimS

I had one more formula to change.

I had to change the top formula to the bottom formula. It seems to
work. Did I do it right?

=IF(B12="","",IF(B11="",IF(D12>=0,D13*-1+I12,IF(D12="",D13*-1+I12))))

=IF(B12="","",IF(B11="",IF(D12>=0,N(D13)*-1+I12,IF(D12="",N(D13)*-1+I12))))
 
T

T. Valko

Did I do it right?

Yeah, it'll work like that but I'd tweak it a little:

=IF(OR(B12="",B11=""),"",IF(D12>=0,-N(D13)+I12,IF(D12="",-N(D13)+I12,"")))
 

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

Similar Threads


Top