If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Rounding & Truncating

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-06, 18:53
gileswb gileswb is offline
Registered User
 
Join Date: May 2006
Location: Oceanside, CA
Posts: 2
Rounding & Truncating

I have a calculated number in a cell with 1 decimal place.
If the decimal is < .5, I want to round it down to an integer,
if it is .5, I want to leave it as is,
and if it is > .5, I want to round it up to the next higher integer.

Does anyone have any suggestions as to how to do this?

Thanks in advance,

Giles.
Reply With Quote
  #2 (permalink)  
Old 05-04-06, 20:51
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
=ROUND(cell,0)

You might like to check it handles negative numbers how you want. And exact xx.5 values

HTH
Reply With Quote
  #3 (permalink)  
Old 05-04-06, 21:30
gileswb gileswb is offline
Registered User
 
Join Date: May 2006
Location: Oceanside, CA
Posts: 2
Rounding & Truncating

I am aready using the round(x,1) function, and it returns the value I am trying to change. Round does not return the result I need.

Giles
Reply With Quote
  #4 (permalink)  
Old 05-04-06, 22:02
Fazza Fazza is offline
Registered User
 
Join Date: Feb 2006
Posts: 113
My mistake, Giles. I didn't read your question fully.

What you want requires a test to know the numbers that are exactly xx.5.

One solution would be
=IF(A1-INT(A1)=0.5,A1,ROUND(A1,0))

Another one
=IF(INT(2*A1)=2*A1,A1,ROUND(A1,0))

Instead of these formulaic approaches, you could create a custom/user defined function in VBA.

HTH,
Fazza
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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