View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Simple Math Question

G.

This may not be as simple as everyone thinks: it depends on the formatting of cell C12.

This will return the ones digit as displayed:
=MOD(ROUND(C12,0),10)

This will return the ones digit no matter how the number is displayed:
=INT(MOD(C12,10))

HTH,
Bernie
MS Excel MVP


"G" wrote in message
...
I want to reduce the code as much as possible with an IF/THEN statement,
here's what I want to do:

Take any number (always less than 120) and get the last digit (only). For
example, if I have 35, I want 5. Right now, I'm doing the following IF/THEN
statement:

C12 = 22 (I want 2)

=IF(C12=30, C12 -30, IF(C12 =20, C12-20, IF(C12=10, C12-10, C12)))

I don't want to write all the code for 120 ... can anyone help me? Thanks.

G