Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Excel strange (erroneous?) decimal behaviour

Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 = 4.469

Can anyone explain this please and how to avoid it?? Could it be that there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel strange (erroneous?) decimal behaviour

Hi DoctorG,

See Chip Pearson's Rounding errors page at:

http://www.cpearson.com/excel/rounding.htm


---
Regards,
Norman



"DoctorG" wrote in message
...
Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 =
4.469

Can anyone explain this please and how to avoid it?? Could it be that
there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel strange (erroneous?) decimal behaviour

? Range("A1").Value
4.469
? Range("A2").Value
4.469
? range("A1").Value*1000/1000
4.469
? range("A2").Value*1000/1000
4.469

I couldn't reproduce it.

--
Regards,
Tom Ogilvy

"DoctorG" wrote in message
...
Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 =

4.469

Can anyone explain this please and how to avoid it?? Could it be that

there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel strange (erroneous?) decimal behaviour

In tools=Options=Calculation tab, make sure precision as displayed is
unchecked.

--
Regards,
Tom Ogilvy


"DoctorG" wrote in message
...
Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 =

4.469

Can anyone explain this please and how to avoid it?? Could it be that

there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Excel strange (erroneous?) decimal behaviour

Hi Doctor G,

Please ignore my suggestion.

I could only reproduce your experience if, as suggested by Tom, I had the '
Precision as displayed ' option selected and I had cell A2 formatted as a 2
decimal place number.

My apologies for my first response.

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi DoctorG,

See Chip Pearson's Rounding errors page at:

http://www.cpearson.com/excel/rounding.htm


---
Regards,
Norman



"DoctorG" wrote in message
...
Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 =
4.469

Can anyone explain this please and how to avoid it?? Could it be that
there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Excel strange (erroneous?) decimal behaviour

Tom, I checked Precision as Displayed and it is not checked.

I was also not able to reproduce it as you tried and I found out that it is
a result of the Currency format, through the Currency button. This button
results in an "Accounting" format with 2 decimals. I change this to 3
decimals through Format Cell, but through VBA--
Range("A2").Value=Range("A1").Value Excel rounds the result.

Does this give you a clue? Can you reproduce it like this?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Excel strange (erroneous?) decimal behaviour

My dear Norman, you mean that deep inside you are human and you happened to
suggest something that wasn't exactly to the point?? Please, just think where
all us out here would be left if you guys (and gals) weren't helping us out.
Thanks for being there. You are all great!

By the way, I am situated in Greece so my Currency button (read my response
to Tom) displays a Euro symbol. Does this have anything to do with the
problem?

"Norman Jones" wrote:

Hi Doctor G,

Please ignore my suggestion.

I could only reproduce your experience if, as suggested by Tom, I had the '
Precision as displayed ' option selected and I had cell A2 formatted as a 2
decimal place number.

My apologies for my first response.

---
Regards,
Norman


"Norman Jones" wrote in message
...
Hi DoctorG,

See Chip Pearson's Rounding errors page at:

http://www.cpearson.com/excel/rounding.htm


---
Regards,
Norman



"DoctorG" wrote in message
...
Cell A1 = 4.469 with 3 decimals numeric format

if cell A2 formula is "=A1" == A2 = 4.469

if in VBA: Range("A2").Value=Range("A1").Value == A2 = 4.470
if in VBA: Range("A2").Value=Range("A1").Value * 1000 / 1000 == A2 =
4.469

Can anyone explain this please and how to avoid it?? Could it be that
there
is a SET DECIMALS TO 2 VBA environment setting that causes a 2-decimal
rounding??






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Excel strange (erroneous?) decimal behaviour

results in an "Accounting" format ...etc
Does this give you a clue?


Yes. You need to use "Value2" instead of "Value."

Range("A2").Value = Range("A1").Value2

HTH. :)
--
Dana DeLouis
Win XP & Office 2003


"DoctorG" wrote in message
...
Tom, I checked Precision as Displayed and it is not checked.

I was also not able to reproduce it as you tried and I found out that it
is
a result of the Currency format, through the Currency button. This button
results in an "Accounting" format with 2 decimals. I change this to 3
decimals through Format Cell, but through VBA--
Range("A2").Value=Range("A1").Value Excel rounds the result.

Does this give you a clue? Can you reproduce it like this?



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Excel strange (erroneous?) decimal behaviour

Dana you are absolutely correct.

I was not aware of "value2" and it seems that it provides the extra
(decimal) precision I needed, as stated in Help.

Thanks a lot.

"Dana DeLouis" wrote:

results in an "Accounting" format ...etc
Does this give you a clue?


Yes. You need to use "Value2" instead of "Value."

Range("A2").Value = Range("A1").Value2

HTH. :)
--
Dana DeLouis
Win XP & Office 2003


"DoctorG" wrote in message
...
Tom, I checked Precision as Displayed and it is not checked.

I was also not able to reproduce it as you tried and I found out that it
is
a result of the Currency format, through the Currency button. This button
results in an "Accounting" format with 2 decimals. I change this to 3
decimals through Format Cell, but through VBA--
Range("A2").Value=Range("A1").Value Excel rounds the result.

Does this give you a clue? Can you reproduce it like this?




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
strange behaviour in Excel 2003 when importing XML Marius Bancila Excel Discussion (Misc queries) 1 October 23rd 06 08:53 AM
Strange behaviour - loading Excel clears Clipboard Trevor Shuttleworth Excel Discussion (Misc queries) 1 August 19th 06 10:04 PM
Strange VBA Behaviour Ricko Excel Programming 0 July 28th 05 07:53 AM
Is there a maximum number of Add-ins allowed? - strange Excel behaviour Bennie Douma Excel Programming 1 July 23rd 04 01:02 AM
Strange behaviour in VBA Help Michael Singmin Excel Programming 4 June 4th 04 07:06 PM


All times are GMT +1. The time now is 04:56 PM.

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

About Us

"It's about Microsoft Excel"