How can I subtract 111 from a number like 097 and get 987, using .

V

Viper5963

I am trying to take a number like 097, subtract 111. I don't want my new
number to become -186, instead I want 986. I am trying to use an IF
statement that looks like this:

=IF(LEFT(A1)
="0","9",LEFT(A1)-1&IF(MID(A1,2,1)="0","9",MID(A1,2,1)-1&IF(RIGHT(A1)="0","9",RIGHT((A1)-1))))

This works fine for the first number, but if I enter new numbers in the
column and copy the formula down, I get invalid data . Please help
 
R

RagDyeR

097 in A1
111 in A2

=A1+1000-A2
--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================



I am trying to take a number like 097, subtract 111. I don't want my new
number to become -186, instead I want 986. I am trying to use an IF
statement that looks like this:

=IF(LEFT(A1)
="0","9",LEFT(A1)-1&IF(MID(A1,2,1)="0","9",MID(A1,2,1)-1&IF(RIGHT(A1)="0","9
",RIGHT((A1)-1))))

This works fine for the first number, but if I enter new numbers in the
column and copy the formula down, I get invalid data . Please help
 
J

Jerry W. Lewis

I can't figure out how you would get -186 instead of -14, but
=MOD(97-111,1000)
is 986.

Jerry
 
D

Dana DeLouis

Not sure since 97-111 equals -14. Would this work?

=MOD(97-111,1000)

returns 986.
 
K

K.S.Warrier

hi,
The question is not clear.
Supposing A1=097,A2=111, 097-111 gives -14.
If you mean that if the result is negative, add 1000 to that,then a formula
can be arrived as
=if(A1-A2<0,A1-A2,A1-A2+1000)
Thank you,
K.S.Warrier
 
V

Viper5963

I am trying to subtract 1 from each position in my number, example position
1=0, position 2=9, position 3=7. 0-1 = -1, 9-1=8, 7-1=6. If the number in
any positon is a zero(0), then I want the new number to become a 9, instead
of a -1. I'm sorry I didn't make that clear in my first post.

Thanks,
Viper5963
 
R

Ron Rosenfeld

I am trying to subtract 1 from each position in my number, example position
1=0, position 2=9, position 3=7. 0-1 = -1, 9-1=8, 7-1=6. If the number in
any positon is a zero(0), then I want the new number to become a 9, instead
of a -1. I'm sorry I didn't make that clear in my first post.

Just add 1000. Or, if the number of digits being subtracted can vary, add
10^numdigits


--ron
 

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