formatting decimal places in code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Try this...

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