PDA

View Full Version : 2 dec. places becomes more than 2 dec. places!



Asterix
01-25-2008, 05:17 AM
I declare variable X as single, populate it with a calculated (e.g.) 14.02.
I put it in a cell (the cell says 14.02).
I format the cell as "0.00" (the cell says 14.02).
Later, in another macro, I copy that cell value to another single variable, Y (according to the debugger, the variable says 14.02).
I create a new spreadsheet and format the numbers as "0.00"
I populate one of the cells I just formatted with the variable value, like this...


Worksheets("Overall standings").Cells(driver_row, event_column).Value = Round(score, 2)

The value in the cell now reads (e.g.) "14.01564333756".

I've tried using "round(variable, 2)" on both X and Y (even though I can see they're only 2 dec. places), still no joy.

Funny thing is, if I were to originally assign X a value of (e.g.) 16.5, I don't have the subsequent problem.

Anyone come across similar?

lynnnow
01-25-2008, 05:30 AM
why not just use the value from the variable instead of using the round syntax? Is "score" a calculated value or something that is a product of some calculation?

Asterix
01-25-2008, 05:34 AM
why not just use the value from the variable instead of using the round syntax?

...already tried both with and without the round syntax (sorry, I should've been clearer), same problem exists.


Is "score" a calculated value or something that is a product of some calculation?

Score is the variable that picks up the 14.02 value from the originally populated cell.

Thanks for replying

lynnnow
01-25-2008, 05:48 AM
declare the variable as Double instead of Single.

Asterix
01-25-2008, 06:23 AM
declare the variable as Double instead of Single.

thx...that worked (rapidly moving on to the next problem)