+ Reply to Thread
Results 1 to 4 of 4

Number format and decimal positions

  1. #1
    Neal Zimm
    Guest

    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. #2
    Vasant Nanavati
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Neal Zimm
    Guest

    Re: Number format and decimal positions

    Hi Vasant,
    Thank you. I don't think I remember reading in the MSO Excel docum re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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. #4
    Vasant Nanavati
    Guest

    Re: Number format and decimal positions

    You're welcome, Neal!

    --

    Vasant

    "Neal Zimm" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Vasant,
    > Thank you. I don't think I remember reading in the MSO Excel docum re:

    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" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1