To work around this issue, use one 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 format
You 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. However, 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.
Note In Microsoft Office Excel 2007, click Format in the Cells group on the Home tab, and then click Format Cells. In the Format Cells dialog box, 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. To do this, follow these steps:
- Click the cell that you want to format.
- On the Format menu, click Cells, and then click the Number tab.
Note In Excel 2007, click Format in the Cells group on the Home tab, and then click Format Cells. In the Format Cells dialog box, click the Number tab. - In the Category list, click Custom.
- In the Type list, click yyyy/mm/dd.
- Click OK.