+ Reply to Thread
Results 1 to 5 of 5

formatting decimal places in code

  1. #1
    cherman
    Guest

    formatting decimal places in code

    I tried to find the answer by searching, but could not.

    I'm using code like the following to format cells. I can do everything I
    want except set decimal places. Is there a way to do this following the
    pattern below?

    With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    .Select
    .Font.Name = "Arial"
    .Font.Size = 8
    .HorizontalAlignment = xlCenter
    End With

    Thanks in advance,
    Clint Herman

  2. #2
    Niek Otten
    Guest

    Re: formatting decimal places in code

    Include something like

    ..NumberFormat = "0.000"

    --
    Kind regards,

    Niek Otten

    "cherman" <[email protected]> wrote in message
    news:[email protected]...
    >I tried to find the answer by searching, but could not.
    >
    > I'm using code like the following to format cells. I can do everything I
    > want except set decimal places. Is there a way to do this following the
    > pattern below?
    >
    > With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    > .Select
    > .Font.Name = "Arial"
    > .Font.Size = 8
    > .HorizontalAlignment = xlCenter
    > End With
    >
    > Thanks in advance,
    > Clint Herman




  3. #3
    Gary''s Student
    Guest

    RE: formatting decimal places in code

    Try:

    ..NumberFormat = "0.000" to format three decimal places.

    Just be sure to use the above srting format or a string variable:

    Dim s as String
    s="0.000"
    ..NumberFormat = s
    --
    Gary''s Student


    "cherman" wrote:

    > I tried to find the answer by searching, but could not.
    >
    > I'm using code like the following to format cells. I can do everything I
    > want except set decimal places. Is there a way to do this following the
    > pattern below?
    >
    > With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    > .Select
    > .Font.Name = "Arial"
    > .Font.Size = 8
    > .HorizontalAlignment = xlCenter
    > End With
    >
    > Thanks in advance,
    > Clint Herman


  4. #4
    Jim Thomlinson
    Guest

    RE: formatting decimal places in code

    Try this...

    With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    .Select
    .Font.Name = "Arial"
    .Font.Size = 8
    .HorizontalAlignment = xlCenter
    .numberformat = "#,##0.00"
    End With


    --
    HTH...

    Jim Thomlinson


    "cherman" wrote:

    > I tried to find the answer by searching, but could not.
    >
    > I'm using code like the following to format cells. I can do everything I
    > want except set decimal places. Is there a way to do this following the
    > pattern below?
    >
    > With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    > .Select
    > .Font.Name = "Arial"
    > .Font.Size = 8
    > .HorizontalAlignment = xlCenter
    > End With
    >
    > Thanks in advance,
    > Clint Herman


  5. #5
    cherman
    Guest

    Re: formatting decimal places in code

    Thanks! I figured it was easy.

    "Niek Otten" wrote:

    > Include something like
    >
    > ..NumberFormat = "0.000"
    >
    > --
    > Kind regards,
    >
    > Niek Otten
    >
    > "cherman" <[email protected]> wrote in message
    > news:[email protected]...
    > >I tried to find the answer by searching, but could not.
    > >
    > > I'm using code like the following to format cells. I can do everything I
    > > want except set decimal places. Is there a way to do this following the
    > > pattern below?
    > >
    > > With objActiveWkb.Worksheets("Sheet1").Cells(I, K)
    > > .Select
    > > .Font.Name = "Arial"
    > > .Font.Size = 8
    > > .HorizontalAlignment = xlCenter
    > > End With
    > >
    > > Thanks in advance,
    > > Clint Herman

    >
    >
    >


+ 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