Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Truncating to two decimals

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Truncating to two decimals

try:
0.01*int( 897.15818*100)


"Phil H" wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Truncating to two decimals

Is there a way to truncate to two decimals without rounding?

Here's one ideas:
=INT(A1*100)/100

but with rounding...
=ROUNDDOWN(A1,2)

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Phil H" wrote in message
...
Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Truncating to two decimals

I use this if rounding isn't an issue

Range("B17:C21").Select
Selection.NumberFormat = "0.00%"
Range("I:I").Select
Selection.NumberFormat = "0.00%"


"Dana DeLouis" wrote:

Is there a way to truncate to two decimals without rounding?


Here's one ideas:
=INT(A1*100)/100

but with rounding...
=ROUNDDOWN(A1,2)

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Phil H" wrote in message
...
Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Truncating to two decimals

On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Truncating to two decimals

=INT(A1*100)%

Regards,
Bernd

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Truncating to two decimals

Thanks Ron, this is exactly what I needed.

"Ron Rosenfeld" wrote:

On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Truncating to two decimals

Glad to help. Thanks for the feedback.



On Fri, 28 Apr 2006 00:13:01 -0700, Phil H
wrote:

Thanks Ron, this is exactly what I needed.

"Ron Rosenfeld" wrote:

On Wed, 26 Apr 2006 22:11:01 -0700, Phil H
wrote:

Is there a way to trunkate to two decimals without rounding? For example:
123.45*31/12 = 318.9125 I need 318.91
234.97*42/11 = 897.15818, I need 897.15


As a worksheet formula, you could just use the TRUNC function:

e.g. =TRUNC(your_formula,2)

In VBA,

Int(your_formula * 100) / 100

or

Fix(your_formula * 100) / 100

depending on how you want to handle negative numbers.


--ron


--ron
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
Count digits before decimals and after decimals Elton Law[_2_] Excel Worksheet Functions 5 April 3rd 23 10:59 AM
Truncating a VIN lputnam Excel Discussion (Misc queries) 3 November 11th 09 05:28 PM
Truncating Decimals RidgeView Excel Discussion (Misc queries) 2 June 21st 09 06:11 PM
numbers truncating Sue Excel Discussion (Misc queries) 3 January 25th 07 12:52 PM
truncating a number in VB Eric[_24_] Excel Programming 5 August 27th 04 04:10 AM


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