+ Reply to Thread
Results 1 to 6 of 6

Restrict Text Format in Text box in Userform

  1. #1
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Restrict Text Format in Text box in Userform

    Dear Forum,

    I have developed an user form and keep one text box to fill date (date picker creates problem in my other team mates system, so i call off it). Now, i want to do few data validation measures for the particular text box.

    1. Text box should be contained only numerical value (date)
    2. The date inputs should be in dd/mm/yyyy format. (1.1.18 means, should be rejected)
    3. The date should not be future date.

    as per my code, 1 and 3 requirements are working perfectly. 2nd requirement only having issue. It shows. "Else without If error"

    Kindly do the needful. Thanks in advance.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Restrict Text Format in Text box in Userform

    Try:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Re: Restrict Text Format in Text box in Userform

    Dear Mr. Kaper,

    Thanks for your guidance on code. But not, none of the date format is accepting by the code. My requirement is, I want to have a date only DD/MM/YYYY in this format. I dont want even d.m.yyyy or dd.mm.yyyy date format.

    Kindly do the needful.

    Regards

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Restrict Text Format in Text box in Userform

    Have you tested my code? (Of course I didn't because there was no test file attached).

    If not - do the test.
    If yes and it do accept wrong formats, provide sample file wiyth sample form.

    To attach an Excel file you have to do the following: Just before posting, scroll down and press Go Advanced button and then scroll down and press Manage Attachments link. Now follow the instructions at the top of that pop-up screen.

  5. #5
    Forum Contributor
    Join Date
    08-19-2016
    Location
    Chennai, India
    MS-Off Ver
    2007
    Posts
    300

    Re: Restrict Text Format in Text box in Userform

    Dear Mr.Kaper,

    As you suggested, i have attached the workbook with your code. Its not allowed any date value or format. Kindly do the needful.

    Thanks in advance
    Attached Files Attached Files

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Restrict Text Format in Text box in Userform

    Hi,

    I expect the code provided shall work fine if there are standard international settinmgs in system. May be you have national settings with different format date?
    You may try using Regular Expresions to test date format. This shall work independently on regional settiongs in system. For instance:

    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. [SOLVED] restrict a search to either text entries or date entries when loading dynamic userform
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2017, 06:06 AM
  2. VBA Userform - Restrict Text Box to integers between 18 - 80
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2013, 03:38 PM
  3. Restrict Text box Text to Actual Size of Text box
    By zhb12810 in forum Excel General
    Replies: 2
    Last Post: 10-07-2012, 03:54 AM
  4. Use spreadsheet cell format to set userform text box format - how?
    By barryleajo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-08-2010, 07:17 AM
  5. Restrict text entry in textbox to JUST TEXT
    By TheNewGuy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-24-2009, 03:54 PM
  6. format userform text box
    By Zygan in forum Excel General
    Replies: 4
    Last Post: 07-12-2006, 10:35 AM
  7. [SOLVED] Restrict date format for UserForm
    By Rob in forum Excel General
    Replies: 2
    Last Post: 12-18-2005, 08:20 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