views:

2236

answers:

5

i'm automating excel, using the macro system as a guide to what i should do through automation. When i formatted a column as a date, the macro generated a NumberFormat for the column to be:

[$-409]m/d/yy h:mm AM/PM;@

i'm trying to decipher what this really means. i gather from googling, that the values in the square brackets are a condition, and that if the condition:

$-409

is met, then it will use the NumberFormat

m/d/yy h:mm AM/PM

if not, it uses the NumberFormat

@

The references i find say that the number format "@" is a Text Placeholder

So my questions are:

  1. What is the conditional $-409 testing? Is it comparing something against -409 (i.e. negative four hundred and nine), and if so, what is the dollar sign it's comparing against?

  2. If the conditional fails, and it resorts to the Text Placeholder "at-sign", what does it show as?

+3  A: 

This post explains it. Basically 409 is the locale ID for "English - United States". If you used [$-414], for example, then the date would be formatted for "Norwegian (Bokmål)" instead.

My guess for question (2) is that the raw data would be presented as a string instead of being formatted. A quick test would verify this.

Naaff
Nice find, and your guess about question 2 is correct. +1
e.James
+1  A: 

[$-409] does not appear to be a condition. It seems to be a Locale code.

If I format a cell with a Custom format of [$-409]m/d/yy h:mm AM/PM;@, enter a date: 1/1/9, then view the formatting for the cell, I see a Date format of m/d/yy h:mm AM/PM with a Locale (location) of English (United States).

If you change the format to something like [$-439]m/d/yy h:mm AM/PM;@ you'll see the contents of the cell in another language.

I'm not sure about @. It might indicate how to display the date if the correct font or locale is not available.

Here is list of Locale IDs Assigned by Microsoft.

Grant Wagner
The @ is a text placeholder. See my response for the dirty details, and thank you for the link to the Locale IDs.
e.James
+3  A: 
e.James
+1  A: 

To clarify what others have said:

The [$-409] is a locale code, given in hexadecimal. Prefixing a date with a certain locale code determines what is shown when you use the various date time format codes. For example using the date

November 28, 1973 11:28:13 AM

as an example for the following table:

Format Code  409 (English United States)  804 (Chinese PRC)
===========  ===========================  =================
m            11                           11
mm           11                           11
mmm          Nov                          十一月
mmmm         November                     十一月
d            27                           27
dd           27                           27
ddd          Mon                          二
dddd         Monday                       星期二
y            73                           73
yy           73                           73
yyy          1973                         1973
yyyy         1973                         1973
AM/PM        AM                           上午

So in the end the same format code with two different locale identifiers, gives different results:

[$-409]mmmm dd yyyy  h:mm AM/PM
November 27 1973  11:28 AM


[$-804]mmmm dd yyyy  h:mm AM/PM
十一月 27 1973  11:28 上午

Since finding a list of locale codes is like pulling teeth, here are some references:

Language Identifier Constants and Strings (Primary source)

Windows Locale Codes Sorted by Locale

Windows Locale Codes Sorted by Locale

Ian Boyd
A: 

There is a bug in Excel 2007 that changes all general formats to a [$-409] type date format.
Normally, use of the [$-409] is an okay format.
There is no fix for the bug yet provided by Microsoft. This Bug normally happens in Large and Shared Excel workbooks.

If you ever have the experience where all of your general formats change to dates try going to Cell Styles, Right clicking on Normal and modifying normal back to general. It will tell you in the box the format type for Normal. This is the bug as it typically should be 'general' not some verison of [$-409].

I ended up having to delete the format from the workbook entirely. The Workbook must be unshared to do this. To delete the Format [$-409] identified above under the "Normal" cell type from the workbook, Right click on a cell, select Custom, scroll until you find the [$-409] format type identified above, delete then all formats will return back to what is called general.

Jeff Taplett