Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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?...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default 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?...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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-
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default 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-



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rounding up decimals Darren Excel Worksheet Functions 2 May 25th 09 01:39 AM
Decimals rounding up Cynthia Excel Discussion (Misc queries) 5 August 17th 07 01:45 AM
Format monetary amount to 9 digits with No decimals without rounding [email protected] Excel Worksheet Functions 4 December 20th 05 11:14 PM
Rounding Decimals Sho Excel Worksheet Functions 6 November 16th 04 02:29 PM
Rounding up decimals MAS Excel Programming 5 July 17th 04 03:05 AM


All times are GMT +1. The time now is 01:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"