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

Include something like

..NumberFormat = "0.000"

--
Kind regards,

Niek Otten

"cherman" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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" wrote in message
...
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
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
Formatting and adding cells formatted to 2 decimal places Colin Excel Worksheet Functions 3 May 5th 08 10:59 PM
conditonally formatting decimal places BigMikeGallagher Excel Discussion (Misc queries) 0 April 6th 06 06:08 PM
Formatting a cell to display varying decimal places. JayE Excel Programming 8 May 21st 05 11:35 PM
Currency Formatting to 3 decimal Places David Dalebroux Excel Programming 1 August 7th 04 09:22 PM
Conditional Formatting - number of decimal places Andrew[_24_] Excel Programming 2 November 12th 03 09:04 PM


All times are GMT +1. The time now is 11:43 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"