Microsoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals 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 needs.
If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified
Partners -
https://partner.microsoft.com/global/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
To reproduce this problem, follow these steps:
- Start Microsoft Excel 2000. On the Tools menu, point to Macro, and click Visual Basic Editor.
- On the View menu, click Immediate Window. Or, press CTRL+G.
- Type the following lines of code in the Immediate window. Press ENTER after you enter each line of code:
?Application.Evaluate("=""2025/7/5""+1")
?Application.Evaluate("=""7/5/25""+1")
?Application.Evaluate("=""25/7/5""+1")
Note the following:
- The first line of code returns the correct result 45844, the serial
number value of July 5, 2025. Even though the date uses year/month/day
date order, the result is correct because the date includes a
four-digit year.
- The second line of code also returns 45844. The result is correct
because the date was entered using month/day/year date order.
- However, the third line of code returns Error 2015 because the date
uses a two-digit year and the date is entered using year/month/day
date order.
Also, if you run the following macro
Sub Test()
MsgBox Application.Evaluate("=""25/7/5""+1")
End Sub
you will receive a run-time error message 13 (type mismatch) error message. The problem occurs because the date uses a two-digit year and is entered using year/month/day date order.