Excel Macro to Convert yymmdd Date Format to a Serial Number

Last reviewed: November 2, 1994
Article ID: Q44736
The information in this article applies to:
  • Microsoft Excel for Windows, versions 2.x, 3.0, 4.0, 4.0a, 5.0

SUMMARY

Dated records from a mainframe may import as yymmdd (for example, January 1, 1991 is represented as 910101) in Excel. The format is not recognized by Excel and must be converted to a serial number.

MORE INFORMATION

The following short macro converts a mainframe date, with no separators, to Excel format:

   A1: <<Name of macro>>
   A2: =DATE(LEFT(ACTIVE.CELL(),2),MID(ACTIVE.CELL(),3,2),
        RIGHT(ACTIVE.CELL(),2))
   A3: =FORMULA(A2)
   A4: =FORMAT.NUMBER("mm-dd-yy")
   A5: =SELECT("R[1]C")
   A6: =IF(ACTIVE.CELL()<>"",GOTO(A2),RETURN())

The above macro assumes the following:

  1. The dates to be converted are arranged in columns.

  2. The active cell is the first date to be converted in the column.

  3. There is an empty cell at the end of the column of dates.


KBCategory: kbusage
KBSubcategory:

Additional words: 5.00 2.10 2.1 3.00 3.0 4.00 4.0


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1994
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.