Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Number format and decimal positions

I am stumped.

this code is part of much larger macro.

Range(Cells(drprw, 6), Cells(drprw + 1, 6)).NumberFormat = "0.00"
numba = Round(qtytpd / qtyroutes, 2)
numbb = Round(tpaftot / qtyroutes, 2)
Cells(drprw, 6) = numba
Cells(drprw + 1, 6) = numbb

the cells are displaying numbers like 9.00 when there should be
non zero decimal positions.

if i pull the code out of the macro, and run it standalone,
it works fine.

all vars are dim'd as long.

i' ve checked the code 'after' this, and there are NO other formating
commands.
I don't know where to 'look' next.

Help. Thanks. Neal.



--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Number format and decimal positions

A Long is an integer, so you will get only integral values for your
variables.

numba and numbb should be DIMmed as Single.

--

Vasant


"Neal Zimm" wrote in message
...
I am stumped.

this code is part of much larger macro.

Range(Cells(drprw, 6), Cells(drprw + 1, 6)).NumberFormat = "0.00"
numba = Round(qtytpd / qtyroutes, 2)
numbb = Round(tpaftot / qtyroutes, 2)
Cells(drprw, 6) = numba
Cells(drprw + 1, 6) = numbb

the cells are displaying numbers like 9.00 when there should be
non zero decimal positions.

if i pull the code out of the macro, and run it standalone,
it works fine.

all vars are dim'd as long.

i' ve checked the code 'after' this, and there are NO other formating
commands.
I don't know where to 'look' next.

Help. Thanks. Neal.



--
Neal Z



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Number format and decimal positions

Hi Vasant,
Thank you. I don't think I remember reading in the MSO Excel docum NOT
being able to get a decimal answer to an 'integer' division.
I also need to apologize, when I extracted the code in a test, I now
remember that I did NOT Dim the vars before running my test, so I guess MSO
dim'd them as variants, and that's why the test worked, but not the code when
it was in the macro.
Again Thanks,
Neal


"Vasant Nanavati" wrote:

A Long is an integer, so you will get only integral values for your
variables.

numba and numbb should be DIMmed as Single.

--

Vasant


"Neal Zimm" wrote in message
...
I am stumped.

this code is part of much larger macro.

Range(Cells(drprw, 6), Cells(drprw + 1, 6)).NumberFormat = "0.00"
numba = Round(qtytpd / qtyroutes, 2)
numbb = Round(tpaftot / qtyroutes, 2)
Cells(drprw, 6) = numba
Cells(drprw + 1, 6) = numbb

the cells are displaying numbers like 9.00 when there should be
non zero decimal positions.

if i pull the code out of the macro, and run it standalone,
it works fine.

all vars are dim'd as long.

i' ve checked the code 'after' this, and there are NO other formating
commands.
I don't know where to 'look' next.

Help. Thanks. Neal.



--
Neal Z




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Number format and decimal positions

You're welcome, Neal!

--

Vasant

"Neal Zimm" wrote in message
...
Hi Vasant,
Thank you. I don't think I remember reading in the MSO Excel docum

NOT
being able to get a decimal answer to an 'integer' division.
I also need to apologize, when I extracted the code in a test, I now
remember that I did NOT Dim the vars before running my test, so I guess

MSO
dim'd them as variants, and that's why the test worked, but not the code

when
it was in the macro.
Again Thanks,
Neal


"Vasant Nanavati" wrote:

A Long is an integer, so you will get only integral values for your
variables.

numba and numbb should be DIMmed as Single.

--

Vasant


"Neal Zimm" wrote in message
...
I am stumped.

this code is part of much larger macro.

Range(Cells(drprw, 6), Cells(drprw + 1, 6)).NumberFormat = "0.00"
numba = Round(qtytpd / qtyroutes, 2)
numbb = Round(tpaftot / qtyroutes, 2)
Cells(drprw, 6) = numba
Cells(drprw + 1, 6) = numbb

the cells are displaying numbers like 9.00 when there should be
non zero decimal positions.

if i pull the code out of the macro, and run it standalone,
it works fine.

all vars are dim'd as long.

i' ve checked the code 'after' this, and there are NO other formating
commands.
I don't know where to 'look' next.

Help. Thanks. Neal.



--
Neal Z






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
Converting decimal number to hh:mm format Jeff Lowenstein Excel Discussion (Misc queries) 2 April 15th 08 08:39 PM
Format for Whole number and 1 Decimal in same Cell Sean Excel Worksheet Functions 4 November 30th 07 01:44 PM
Custom format whole number to decimal TamIam Excel Worksheet Functions 7 August 7th 07 04:44 PM
Number format still uses decimal point BecknRoos New Users to Excel 3 April 9th 07 06:32 AM
I want to format a number cell without the decimal and without ro. LAM Excel Discussion (Misc queries) 8 April 20th 05 04:59 PM


All times are GMT +1. The time now is 04:53 PM.

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

About Us

"It's about Microsoft Excel"