+ Reply to Thread
Results 1 to 3 of 3

day and month switching in VBA userform

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    Nottingham, England
    MS-Off Ver
    2010, 2013
    Posts
    37

    day and month switching in VBA userform

    Hi,

    I have created a userform that contains text boxes and command buttons. When I enter a date dd/mm/yyyy through the userform it displays as mm/dd/yyyy on the worksheet. I have the cells formatted to date, locale English (U.K.), however this still switches the date.

    Is is possible to specify the date format in both the VBA userform and then in the column in the worksheet , to keep the date as dd/mm/yyyy



    I've also seen that you can do something along the lines of :

    Dim mydate As Date
    mydate = sesdatetext.value
    .Cells(lRow, 8).Value = mydate

    However, I can't seem to get this to work..

    Attached is the workbook, any ideas/corrections are welcome!

    Thanks, WWM
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: day and month switching in VBA userform

    Leaving Date conversations to VBA means they will be assumed to be American format - 01/03/16 is Jan 3, not 1 March. There's no problem if the date is not ambiguous between the 2 formats, 23/11 can only ever be 23 November.

    Convert the Date (strings) in the textbox to dates using cDate(), which follows your regional settings. '1/3' will then convert to 1st of March.


    Please Login or Register  to view this content.
    Last edited by grimes0332; 03-02-2016 at 06:25 AM.

  3. #3
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: day and month switching in VBA userform

    .Cells(row,column).Value = Format(YourDate,"dd/mm/yyyy") may be a helpful command
    <---If my answer helped, please click *

+ 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. Multi-Page Userform error switching pages
    By henryBukowski in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-06-2016, 09:23 PM
  2. [SOLVED] Userform with Multi-Tabs and Textboxes losing values when switching tabs
    By guitarsweety in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-23-2014, 11:35 AM
  3. Replies: 7
    Last Post: 07-23-2014, 06:15 AM
  4. Userform in Excel 2013 disappears while switching an active workbook behind
    By blackarrow in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-17-2013, 09:08 AM
  5. [SOLVED] Switching Userform Error
    By amotto11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-06-2013, 05:18 PM
  6. Excel is switching date formats between userform and worksheet
    By madbloke in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-09-2008, 03:11 AM
  7. Capture worksheet switching inside userform and update textboxes to new sheet
    By RockiesMan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2007, 05:10 PM

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