View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Rounding Problem

Also, what I don't understand is why the extra decimal positions were there
in the first place. The number I enter using the program had already been
rounded to a single decimal point. Why did excel generate the extra
positions?

Mike


"Bob Umlas, Excel MVP" wrote:

Format the cells with one decimal place, then use Tools/Options/Calculation
tab, and check "Precision as displayed". Click OK to the message about losing
accuracy.
Bob Umlas
Esxcel MVP

"Mike" wrote:

I'm having a problem with rounding that I hope someone can help with. I've
written code in VB to take readings from a piece of test equipment and round
the value to a single decimal point before putting it into a spreadsheet.
The problem is that the actual values in the cells have 13 decimal places.
The cells are formatted as a number with one decimal place and that is how
they are displayed in the cell of the spreadsheet. But, when I click on the
cell and the actual value in shown in the Formula Bar, it shows the value
with 13 decimals places.

Code:
Dim TempStr As Single
TempStr = Round(Mid(ValueStr, 2, 14), 1)
Sheets("Temps").Cells(Rrow, (X * 2)) = TempStr

Results:
Cell Shows in Formula Bar
23.7 23.7000007629394
23.8 23.7999992370605
23.9 23.8999996185302
24.0 24
24.1 24.1000003814697
24.2 24.2000007629394
24.3 24.2999992370605
24.4 24.3999996185302
24.5 24.5
24.6 24.6000003814697
24.7 24.7000007629394
24.8 24.7999992370605
24.9 24.8999996185302
25.0 25