View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default .NumberFormat not getting applied?

On Sat, 17 May 2008 08:51:34 -0700 (PDT), PeteCresswell
wrote:

---------------------------------------------------------------------------------
Const mFormat_DollarAmount As String = "#,##0.00"


4140 With .Columns(mColNum_FP_AmountOutstanding)
4141 .ColumnWidth = 15
4142 .NumberFormat = mFormat_DollarAmount
4143 .HorizontalAlignment = xlRight
4149 End With
---------------------------------------------------------------------------------

The width and horizontal alignments are working, but
the .NumberFormat is not.

Same problem with date columns:
---------------------------------------------
Const mFormat_Date="mm/dd/yyyy"
.NumberFormat = mFormat_Date
--------------------------------------------

Some limitation on what I can do at the column level?


You don't post much of your code, so it's hard to know where the problem is.

Some of the possibilities include an improper declaration of the columns
property; use of this code snippet with a function (it would need to be in a
sub).

Here is a short routine demonstrating several different ways of setting formats
for an entire column, none of which match what you have written:

=============================
Option Explicit
Sub colfmt()
Dim c As Range
Set c = Range("a1")
c.EntireColumn.NumberFormat = "mm/dd/yyyy"
Columns(2).NumberFormat = "mm/dd/yy"

With Columns(3)
.NumberFormat = "mm/dd/yy"
.ColumnWidth = 25
.HorizontalAlignment = xlCenter
End With
End Sub
==================================
--ron