+ Reply to Thread
Results 1 to 3 of 3

convert date 1900

Hybrid View

Guest convert date 1900 02-25-2005, 12:06 PM
Guest Re: convert date 1900 02-25-2005, 03:06 PM
Guest Re: convert date 1900 02-26-2005, 03:06 PM
  1. #1
    Rainer Welzel
    Guest

    convert date 1900

    I tried to force a date column to a text column by
    inserting a tick before the date.
    This works fine but if the date 01.01.1900
    the result is '31.12.1899 .

    the macro line is :
    Dim cell As Range
    ...
    cell = "'" & cell

    what is wrong ?

    thx for your help
    rainer



  2. #2
    Dave Peterson
    Guest

    Re: convert date 1900

    maybe you could use:

    cell.value = "'" & cell.text



    Rainer Welzel wrote:
    >
    > I tried to force a date column to a text column by
    > inserting a tick before the date.
    > This works fine but if the date 01.01.1900
    > the result is '31.12.1899 .
    >
    > the macro line is :
    > Dim cell As Range
    > ..
    > cell = "'" & cell
    >
    > what is wrong ?
    >
    > thx for your help
    > rainer


    --

    Dave Peterson

  3. #3
    Myrna Larson
    Guest

    Re: convert date 1900

    What is wrong is that Excel worksheet dates incorrectly (but intentionally)
    treat 1900 as a leap year. It wasn't. On a worksheet, a cell containing the
    number 1 is Jan 1, 1900; the number 60 is Feb 29, 1900.

    But the error re 1900 not being a leap year is not present in VBA, and the
    method used to make the correction was to simply make 60 represent Feb 28,
    1900, 1 represent Dec 31, 1899, etc.

    So your code will produce "errors" for all dates between Jan 1, 1900 and Feb
    28, 1900. You'll could build in a check for that, or write your code this way:

    Cell.Value = "'" & Cell.Text

    On Fri, 25 Feb 2005 16:44:53 +0100, "Rainer Welzel" <master@fgg-welzel.de>
    wrote:

    >I tried to force a date column to a text column by
    >inserting a tick before the date.
    >This works fine but if the date 01.01.1900
    >the result is '31.12.1899 .
    >
    >the macro line is :
    >Dim cell As Range
    >..
    >cell = "'" & cell
    >
    >what is wrong ?
    >
    >thx for your help
    >rainer
    >



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1