Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

.NumberFormat not getting applied?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PeteCresswell - 17 May 2008 16:51 GMT
---------------------------------------------------------------------------------
        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?
JLGWhiz - 17 May 2008 17:27 GMT
Can't duplicate the problem.  Code works fine for me.

> ---------------------------------------------------------------------------------
>          Const mFormat_DollarAmount             As String = "#,##0.00"
[quoted text clipped - 16 lines]
>
> Some limitation on what I can do at the column level?
Dave Peterson - 17 May 2008 17:36 GMT
Any chance that you're looking at the wrong column???  You didn't show what that
.columns(...) referred to.

And two wild guesses...

Do you have merged cells in that range?
What's the style for that range?  Is it something special or is it Normal?

Does the code work on a brand new worksheet?

> ---------------------------------------------------------------------------------
>          Const mFormat_DollarAmount             As String = "#,##0.00"
[quoted text clipped - 16 lines]
>
> Some limitation on what I can do at the column level?

Signature

Dave Peterson

Ron Rosenfeld - 17 May 2008 17:55 GMT
>---------------------------------------------------------------------------------
>         Const mFormat_DollarAmount             As String = "#,##0.00"
[quoted text clipped - 16 lines]
>
>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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.