+ Reply to Thread
Results 1 to 4 of 4

VBA Date to DD/MM/YYYY

  1. #1
    Forum Contributor
    Join Date
    01-12-2021
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    118

    VBA Date to DD/MM/YYYY

    I have a textbox in a userform where a date can be added. To make sure it is in DD/MM/YYYY format I use CDATE function. e.g. .Range(1) = CDate(Me.DATE.Value).

    However:
    1) If I leave this textbox empty it results in an error message as there is no date input.
    2) If I remove the CDate function e.g. .Range(1) = Me.DATE.Value, it results in MM/DD/YYYY.

    My excel is set to UK date mode.

    How do I make it optional to enter a date in the textbox AND for it to be in DD/MM/YYYY format?

    Thanks!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VBA Date to DD/MM/YYYY

    Try:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    01-12-2021
    Location
    Australia
    MS-Off Ver
    2010
    Posts
    118

    Re: VBA Date to DD/MM/YYYY

    Thanks TMS!! Works perfectly in my spreadsheet

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VBA Date to DD/MM/YYYY

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Multi Column Listbox returning date as mm-dd-yyyy instead of dd-dmm-yyyy
    By Dotreena in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-08-2020, 08:15 PM
  2. Replies: 3
    Last Post: 04-25-2019, 11:05 AM
  3. Replies: 3
    Last Post: 07-14-2016, 06:36 PM
  4. Replies: 8
    Last Post: 10-02-2013, 06:23 PM
  5. Replies: 7
    Last Post: 11-18-2012, 02:28 PM
  6. [SOLVED] Imported data contains strings dd.mm.yyyy how can I convert to date format dd/mm/yyyy inVB
    By Boormo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-05-2012, 05:48 PM
  7. [SOLVED] opening excel file -> date format problem: DD/MM/YYYY vs MM/DD/YYYY
    By yung in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-18-2005, 09:06 AM

Tags for this Thread

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