![]() |
Why won't this allow decimals...instead it keeps rounding...and won't format correctly.
Alright, I know this is a very 'newbie' question, but it's beating my
brain-pan, and I'm coming up on a deadline. I have a form that collects the data and posts to spreadsheet. Although the col is formatted as currency with specific format (###0.00), when the data is written, it will only us significant numbers and rounds decimals. (1 instead of 1.00, 5 instead of 5.00, etc.) Another macro pulls this info and tries to produce $$ amts for a total value (colA * colB = $$ in colC). Even with reformatting, and converting (CCurr), colC only shows signigicant no. (ColC formatted as Currency with mask: ###0.00) Still it only shows 1 or 2 (like an integer). For decimals it rounds them (0.75 = 1, 0.5 = 0). Thus, the summing of the $$ amts is wrong. I have checked the whole code and used(converted to) Currency, Short, Long, etc...but still no success.... ....WHAT am I doing wrong?... |
Why won't this allow decimals...instead it keeps rounding...and won't format correctly.
<, Short, Long,
Use Double instead Probably the decimals are lost somewhere in your code. Post the code if you can't fix it -- Kind regards, Niek Otten "Terry Cobb" wrote in message . .. Alright, I know this is a very 'newbie' question, but it's beating my brain-pan, and I'm coming up on a deadline. I have a form that collects the data and posts to spreadsheet. Although the col is formatted as currency with specific format (###0.00), when the data is written, it will only us significant numbers and rounds decimals. (1 instead of 1.00, 5 instead of 5.00, etc.) Another macro pulls this info and tries to produce $$ amts for a total value (colA * colB = $$ in colC). Even with reformatting, and converting (CCurr), colC only shows signigicant no. (ColC formatted as Currency with mask: ###0.00) Still it only shows 1 or 2 (like an integer). For decimals it rounds them (0.75 = 1, 0.5 = 0). Thus, the summing of the $$ amts is wrong. I have checked the whole code and used(converted to) Currency, Short, Long, etc...but still no success.... ...WHAT am I doing wrong?... |
Why won't this allow decimals...instead it keeps rounding...and won't format correctly.
Mr. Otten -- First of all 'thank you' for your kind reply.
Without copying in the whole code, here's the scenario... Raw Data works fine: Col1 * Col2 = Col3 2 * 1 = 2 3 * 2 = 6 .50 * 1 = .5 .75 * 2 = 1.5 But when run through a variable, it rounds the decimals and doesn't report the correct mask: dim a as currency dim b as integer dim c as currency a = cells(1,1) b = cells(2,1) c = a * b d = format(c, "####0.00") results in: ColA ColB = ColC ColD 2 1 2 2 3 2 6 6 .50 1 0 0 .75 2 3 3 Thank you for your suggestion. I will try it, and possibly this explains it a little better. Thank you for your time. -tc- |
Why won't this allow decimals...instead it keeps rounding...and won't format correctly.
<dim b as integer
Should probably be Dim b as Double Also, it is clear that this code wasn't pasted from your program. Post again if you still have problems, but do paste the complete code from your program -- Kind regards, Niek Otten "Terry Cobb" wrote in message . .. Mr. Otten -- First of all 'thank you' for your kind reply. Without copying in the whole code, here's the scenario... Raw Data works fine: Col1 * Col2 = Col3 2 * 1 = 2 3 * 2 = 6 .50 * 1 = .5 .75 * 2 = 1.5 But when run through a variable, it rounds the decimals and doesn't report the correct mask: dim a as currency dim b as integer dim c as currency a = cells(1,1) b = cells(2,1) c = a * b d = format(c, "####0.00") results in: ColA ColB = ColC ColD 2 1 2 2 3 2 6 6 .50 1 0 0 .75 2 3 3 Thank you for your suggestion. I will try it, and possibly this explains it a little better. Thank you for your time. -tc- |
Why won't this allow decimals...instead it keeps rounding...and won't format correctly.
integer X double = integer.
The decimal gets truncated with integer calcs. But we would like to see more of your code to give you an accurate answer. -Scrawny |
All times are GMT +1. The time now is 06:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com