View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_5_] Stuart[_5_] is offline
external usenet poster
 
Posts: 413
Default "Rounding" error

Here is the data:

C F I J N O
1.17 4.45 2.79 7.24 8.47 8.47
1.23 2.12 2.12 2.61 2.61

7.81

7.81 is the sum of values in col F multiplied by their corresponding
value in col C.
So 7.81 should equal (1.17 * 4.45) + (1.23 * 2.12)
ie 5.2065 + 2.6076 = 7.8141 round to 7.81

However, I need each multiplication to round. So
1.17 * 4.45 = 5.2065 = 5.21 and
1.23 * 2.12 = 2.6076 = 2.61
thus 5.21 + 2.61 = 7.82

Here's the code that currently sums the column:

For ColNdx = 5 To 9 'cols E to I
Cells(EndToCollectionRow - 1, ColNdx).FormulaArray = "=SUM((" & Range( _
Cells(StartToCollectionRow, "C"), Cells(EndToCollectionRow - 2, "C")) _
.Address & ")*(" & Range(Cells(StartToCollectionRow, ColNdx), _
Cells(EndToCollectionRow - 2, ColNdx)).Address & "))"
Cells(EndToCollectionRow - 1, ColNdx).Value = _
Cells(EndToCollectionRow - 1, ColNdx).Text
Next ColNdx

Is there a way to modify the code, please?

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004