+ Reply to Thread
Results 1 to 3 of 3

VBA to force year to YYYY

  1. #1
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    VBA to force year to YYYY

    Hi. I'm using the following code (this is a the beginning) for a user input where the user has to enter a date. Now whilst the VBA says to enter DD/MM/YYYY, i want to make it so if a user decides to input YY/DD/MM it automatically formats YYYY.
    Please Login or Register  to view this content.
    does format the cell to DD/MM/YYYY if the user has entered DD/MM/YY it doesn't change it to YYYY.

    Here's the code:

    Please Login or Register  to view this content.
    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    08-14-2012
    Location
    Derby, England
    MS-Off Ver
    Excel 2010
    Posts
    257

    Re: VBA to force year to YYYY

    Ok, i've sorted it:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA to force year to YYYY

    Here is an easy way inputting the date as a string:

    Please Login or Register  to view this content.
    so if the user inputs Christmas 2013 as

    25/12/2013

    Christmas gets entered with the correct format, but if the user inputs Christmas 2013 as

    13/12/25

    Christmas still gets entered with the format "YYYY"
    Gary's Student

+ 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