Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default Rounding IF statement?

Hello,
I'd like to setup a roundup or rounddown if statement stating:
If the value of A1 is x.1 to round up to the next whole number; ie (if A1 =
2.1 to round up to 3) but if A1 is x.0x to round down to the next whole
number; ie ( if A1 = 2.09 to round down to 2)

Is this at all possible?
TIA
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Rounding IF statement?

try this...

=IF(MOD(A4,1)<0.1,ROUNDDOWN(A4,0),ROUNDUP(A4,0))
--
HTH...

Jim Thomlinson


"Matt" wrote:

Hello,
I'd like to setup a roundup or rounddown if statement stating:
If the value of A1 is x.1 to round up to the next whole number; ie (if A1 =
2.1 to round up to 3) but if A1 is x.0x to round down to the next whole
number; ie ( if A1 = 2.09 to round down to 2)

Is this at all possible?
TIA

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 860
Default Rounding IF statement?

Hi Matt,

This will work but there's probably a daintier way to do it.

=IF(A1-INT(A1)<0.1,ROUNDDOWN(A1,0),ROUNDUP(A1,0))

HTH
Martin


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 92
Default Rounding IF statement?

=INT(A1+.9)

Regards,
Bernd

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 860
Default Rounding IF statement?

Bloody Hell Bernd,

I know I said "daintier", but that is just downright immoral!!

Martin







  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 516
Default Rounding IF statement?

LOL

thanks everyone! They all seem to be doing the trick.
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 837
Default Rounding IF statement?

How precisely do you need to recognize the boundary condition? Excel works
in binary, and the decimal fraction .1 has no exact representation in binary,
so writing formulas that will always to the right thing at the boundary is
not trivial.

Jim and Martin's solutions round down in many case where they should round
up, such as 4.1.

Bernd's solution rounds up in many cases where it should round down, such as
0.0999999999999999.

I think that
=IF(A1-(INT(A1)+0.1)<0,ROUNDDOWN(A1,0),ROUNDUP(A1,0))
will always correctly recognize the boundary.

Jerry

"Matt" wrote:

Hello,
I'd like to setup a roundup or rounddown if statement stating:
If the value of A1 is x.1 to round up to the next whole number; ie (if A1 =
2.1 to round up to 3) but if A1 is x.0x to round down to the next whole
number; ie ( if A1 = 2.09 to round down to 2)

Is this at all possible?
TIA

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
SQL concatenation statement CLamar Excel Discussion (Misc queries) 0 June 29th 06 01:58 PM
SET statement tutorial Daminc Excel Discussion (Misc queries) 13 January 17th 06 04:47 PM
If statement w/ rounding but not all numbers AMarie Excel Worksheet Functions 5 October 10th 05 08:58 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM


All times are GMT +1. The time now is 01:52 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"