+ Reply to Thread
Results 1 to 7 of 7

Userform switch day with month

  1. #1
    Forum Contributor
    Join Date
    08-01-2012
    Location
    rotterdam, holland
    MS-Off Ver
    Excel 2013
    Posts
    170

    Userform switch day with month

    My Userform switches the months and day somehow. My regional setting in windows are European (ddmmyyyy). But the userform fills in a date that has an english date format.I tried to change it with the CDate thing as you can see below. It works only if I fill in ALL txt boxes with CDate, but its giving me an error if I fill in only a few textboxes with the CDate: txtIN and txtEIND. How can I correct it? (I want date format dd/mm/yyyy) Its giving me the type mismatch. See attachment, press button to start. (fill in 'Unit', 'Datum In' and 'Eind Huur' Thanks! test.xlsm

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Userform switch day with month

    Eh, the UK format is also ddmmyyyy.

    Add code to check if the txtIN, txtOut are empty before using CDate.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-01-2012
    Location
    rotterdam, holland
    MS-Off Ver
    Excel 2013
    Posts
    170

    Re: Userform switch day with month

    Still error, attachment: test.xlsm

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Userform switch day with month

    Why didn't you add the check for the other date fields?

  5. #5
    Forum Contributor
    Join Date
    08-01-2012
    Location
    rotterdam, holland
    MS-Off Ver
    Excel 2013
    Posts
    170

    Re: Userform switch day with month

    Sorry, add the check for other date fields? I dont get it

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Userform switch day with month

    You have 4 date fields/controls txtIN, txtOUT, txtSTART and txtEIND, you need to add a check for "" for each one of them, not just txtIN and txtOUT.

  7. #7
    Forum Contributor
    Join Date
    08-01-2012
    Location
    rotterdam, holland
    MS-Off Ver
    Excel 2013
    Posts
    170

    Re: Userform switch day with month

    Oh right, thanks! I got it working like this

    Please Login or Register  to view this content.

+ 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. UserForm month
    By adeleex in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-09-2011, 12:39 PM
  2. How to switch from userform to shhet and back
    By gonen in forum Excel General
    Replies: 16
    Last Post: 08-17-2011, 12:23 PM
  3. Problem w Code to switch month and year
    By ChemistB in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-09-2011, 04:19 PM
  4. Switch focus to inactive userform
    By GrahamUNC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2005, 05:06 PM
  5. UserForm to select current month or earlier
    By Steve in forum Excel General
    Replies: 4
    Last Post: 01-23-2005, 05:33 PM

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