Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
G G is offline
external usenet poster
 
Posts: 52
Default Simple Math Question

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
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,240
Default Simple Math Question

G wrote:
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



=MOD(C12,10)
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 694
Default Simple Math Question

Hi G
Try this =RIGHT(C12,1)
HTH
John
"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


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 69
Default Simple Math Question

=right(c12,1)


H S Shastri

=================================================

"G" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 70
Default Simple Math Question

Hi G,

you can use following:-

=RIGHT(C12,1)
please let me know, if you still want to do it using if-then. thanks
--
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"G" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Simple Math Question

Maybe

=RIGHT(C12,1)+0

Mike

"G" wrote:

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

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,646
Default Simple Math Question

=VALUE(RIGHT(C12))

Regards,
Stefi

G ezt *rta:

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

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 69
Default Simple Math Question

May be

=Right(c12,1)+a1*0+b1*0+c1*0+d1*0


================================================== =========

"Mike H" wrote:

Maybe

=RIGHT(C12,1)+0

Mike

"G" wrote:

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

  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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



  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Simple Math Question

And what would be the point of that all you would end up with is the righmost
number/character in C12

"HARSHAWARDHAN. S .SHASTRI" wrote:

May be

=Right(c12,1)+a1*0+b1*0+c1*0+d1*0


================================================== =========

"Mike H" wrote:

Maybe

=RIGHT(C12,1)+0

Mike

"G" wrote:

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



  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Simple Math Question

Perhaps he didn't realise that the +0 was there to convert the string to a
number?
But if he was trying to say that the formula was over-complicated, he could
have pointed out that the ,1 is superfluous.
--
David Biddulph

"Mike H" wrote in message
...
And what would be the point of that all you would end up with is the
righmost
number/character in C12

"HARSHAWARDHAN. S .SHASTRI" wrote:

May be

=Right(c12,1)+a1*0+b1*0+c1*0+d1*0


================================================== =========

"Mike H" wrote:

Maybe

=RIGHT(C12,1)+0

Mike

"G" wrote:

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



  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Simple Math Question

David,

I think the former and while I agree about the 1 I'll continue to put it
there to add clarity but perhaps next time I'll use *1 at the end and cause
total confusion.

Mike

"David Biddulph" wrote:

Perhaps he didn't realise that the +0 was there to convert the string to a
number?
But if he was trying to say that the formula was over-complicated, he could
have pointed out that the ,1 is superfluous.
--
David Biddulph

"Mike H" wrote in message
...
And what would be the point of that all you would end up with is the
righmost
number/character in C12

"HARSHAWARDHAN. S .SHASTRI" wrote:

May be

=Right(c12,1)+a1*0+b1*0+c1*0+d1*0


================================================== =========

"Mike H" wrote:

Maybe

=RIGHT(C12,1)+0

Mike

"G" wrote:

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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Math ? Steve B Excel Discussion (Misc queries) 6 January 7th 09 05:59 PM
Simple Math acss Excel Worksheet Functions 9 June 25th 08 07:02 PM
simple math formula Gabriel Excel Discussion (Misc queries) 3 August 25th 06 03:25 PM
simple math equation Richard Excel Discussion (Misc queries) 8 February 18th 06 08:42 PM
Need help, simple math...from a percentage cfiser Excel Discussion (Misc queries) 2 November 17th 05 04:50 PM


All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"