The VBA function Application.International(xlMonthLeadingZero) returns a False value in the Japanese version of Excel (904128)
The information in this article applies to:
- Microsoft Office Excel 2003
- Microsoft Excel 2002
- Microsoft Excel 2000
SYMPTOMSYou experience the following behavior when you use the Japanese version of Microsoft Excel: - When you use the following Microsoft Visual Basic for Applications (VBA) function, the function returns a False value:
Application.International(xlMonthLeadingZero) - The dates appear in the "yyyy/m/d" format instead of the "yyyy/mm/dd" format. That is, the leading zero does not appear in the months or in the dates that have a single digit. For example, the date "June 3, 2005" appears as "2005/6/3" instead of "2005/06/03".
CAUSEThis issue occurs if the Short date format setting in Regional and Language Options is set to yyyy/mm/dd. The Japanese version of Excel ignores this setting. Instead, the Japanese version of Excel uses the "yyyy/m/d" format. Therefore, the VBA function returns a False value when the XlApplicationInternational constant xlMonthLeadingZero is used as the parameter for the International() function.WORKAROUNDTo work around this issue, use either of the following methods. Note The following methods affect the date format and how dates appear in the workbook. These methods do not work around the VBA issue in which the International() function returns a False value.
Use a VBA macro to create the date formatYou can use a VBA macro to set the number format of each cell that contains a date. For example, you can use the following macro to set the number format of cell A1 of a spreadsheet so that the date appears in the "yyyy/mm/dd" format. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
Sub FormatA1()
Range("A1").Value = "2005/06/03"
Range("A1").NumberFormat = "yyyy/mm/dd"
End Sub
Manually format the cells To manually format the cells, create a custom number format, and then apply the custom number format to any cell in the workbook. To create a custom number format, follow these steps:
- On the Format menu, click Cells, and then click the Number tab.
- In the Category list, click Custom.
- In the Type box, type yyyy/mm/dd, and then click OK.
After you create the custom number format, apply this number format to any cell in the workbook: - Click the cell that you want to format.
- On the Format menu, click Cells, and then click the Number tab.
- In the Category list, click Custom.
- In the Type list, click yyyy/mm/dd.
- Click OK.
Modification Type: | Major | Last Reviewed: | 7/13/2005 |
---|
Keywords: | false Italian Application short DATE Options language regional kbprb kbtshoot KB904128 kbAudDeveloper |
---|
|