+ Reply to Thread
Results 1 to 12 of 12

UserForm TextBox Date Format with Automatic Dashes

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    San Luis Obispo, CA
    MS-Off Ver
    Excel 2007
    Posts
    13

    UserForm TextBox Date Format with Automatic Dashes

    Hello, I have the following code:

    Please Login or Register  to view this content.
    I have this located behind a userform that takes in numerical values for a date textbox. This code helps to format it in the proper way I want it. However, I run into a problem when I enter a month that has a zero in front of it. For example 08-21-2012, is not recognized by this code.

    Any Ideas?

    Thanks,

    Saucey

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: UserForm TextBox Date Format with Automatic Dashes

    try this
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Registered User
    Join Date
    08-17-2012
    Location
    San Luis Obispo, CA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: UserForm TextBox Date Format with Automatic Dashes

    Hi John55,

    Thanks for your reply, but your code gives me an 'Overflow' error. I've isolated the part of the code (my original and your proposed solution) in the attached Macro-Enabled Excel Document.

    ~Saucey

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: UserForm TextBox Date Format with Automatic Dashes

    I do not have that err
    Attached Images Attached Images
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-17-2012
    Location
    San Luis Obispo, CA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: UserForm TextBox Date Format with Automatic Dashes

    Hello John,

    Thank you for your help, but I think it gives the user the error when he or she does not type dashes in between. I want to be able to make it where the user simply types in the numbers and the date is formatted correctly as a short date with dashes.

    ~Saucey
    Attached Images Attached Images

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: UserForm TextBox Date Format with Automatic Dashes

    I would use a calendar to force the user...

  7. #7
    Registered User
    Join Date
    09-12-2011
    Location
    Manitoba
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: UserForm TextBox Date Format with Automatic Dashes

    Hi Saucy,

    I have used the following code in my userform, it works well for me:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-17-2012
    Location
    San Luis Obispo, CA
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: UserForm TextBox Date Format with Automatic Dashes

    @John

    Dude you rock! Your calendar works great! Very user friendly! Did you make it? Or did you download it from somewhere?

    FYI future readers: Make sure you transfer the appropriate modules and class modules over to your excel vbe

    @DianneDB

    Sorry, I didn't get your code to work :-(

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: UserForm TextBox Date Format with Automatic Dashes

    saucey, I am glad it works for you!
    No, I did not make it, I saw many solutions here using this calendar! I am not sure who made it but it's great!

  10. #10
    Registered User
    Join Date
    04-03-2013
    Location
    Hyderabd
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: UserForm TextBox Date Format with Automatic Dashes

    Hi John,

    i am using your code to show the calendar but i am getting User-defined error when i ran the code. Could you please tell me how to define "Dim Buttons() As New clsCmdButton". I am getting an error here.

    regards
    Prathap

  11. #11
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: UserForm TextBox Date Format with Automatic Dashes

    hi puthireddy
    and welcome!

    please open your thread and ask for help right there!

  12. #12
    Registered User
    Join Date
    04-03-2013
    Location
    Hyderabd
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: UserForm TextBox Date Format with Automatic Dashes

    Hi John,

    Thanks for your response. I had created a Userform with few textboxes and i want to see a calender when the cursor goes to one of the textbox. I had used your code but i got an error saying "User defined error" for "DIm Button() as New clsCmdButton". I would like to check with you how i can generate this clsCmdButton. Because in your excel file it showing in propety window but it not showing in my excel file. Please help on this.


    Regards
    Prathap

+ 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