View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Undesired Rounding in VBA; accumulating values

? ActiveCell.NumberFormat
$#,##0.00
? typename(activecell.Value)
Currency

--
Regards,
Tom Ogilvy

Ron Rosenfeld wrote in message
...
On 25 Jan 2004 08:12:16 -0800, (Glenn Ray) wrote:

"Pecision as Displayed" is turned off. Format for both source and
destination cells is "$0.00" (Currency, "$", 2 digits).

I actually solved the problem last night by making the following
change in the accumulating formula:
Destination Sheet accumulating:
ActiveCell.Offset(Row, Column).Value = _
ActiveCell.Offset(Row,Column).Value2 + dblArray(RV,CV)

This corrected the rounding I was seeing, but I didn't expect the
error in the previous case in any regard.


I don't believe there should be any difference between Value and Value2

unless
you were using Currency or Date data types.

But if the format of the destination cells is set to 2 digits, then the

display
in those cells will be arithmetically rounded to two digits. So 0.245

will be
displayed as 0.25; although the contents of the cell should still be

0.245.

You could determine the latter by temporarily reformatting the cell to

have
more decimal digits.


--ron