+ Reply to Thread
Results 1 to 5 of 5

How to define date format in userform

  1. #1
    Forum Contributor
    Join Date
    04-27-2010
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    115

    How to define date format in userform

    Hi,

    I have two issues regarding my userform, and i need all the help i can get:

    1st - I have a txtbox in the userform created to insert date "dd-mm-yyyy", but i donīt get any error message if the user inserts text or something else. I need the user to only be allowed to insert dd-mm-yyyy. I've tryed searching the txtbox properties mas i can't find it.

    2nd - The userform sents data to one wsheet. What i need is to create 12 wsheets (12 months) and depending on the month that a certain data is inserted, that data would be sent to the correct wsheet.
    Example: if i submit data in 20-06-2010, the data would be sent to the wsheet"June"

    That would reaaly make my work easier.

    Thanks in advance

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: How to define date format in userform

    First, I've got to give you my Access pitch. Access is built specifically to hold the type of data you seem to be working with. Additionally, Access's forms have built in data validation, so you don't have to use extra code to make sure the user is putting the right value in. I strongly recommend you consider Access for your current project.

    That said, here is an example of how to do what you are doing in excel. See attached workbook.
    Attached Files Attached Files
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Contributor
    Join Date
    04-27-2010
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: How to define date format in userform

    Thanks,

    But i can't seem to use your userform, it keeps giving the msg "You have not entered a valid date. Please enter a valid date in the lower textbox.".

    I've sent you the userfom i'm working in, to see if you can help me again.

    As you can see i have the userform in the sheet "Pagina inicial" and the other sheet "Base Dados" is where the data is sent to.

    What i want to do is to eliminate that sheet and create 12 (months). Then, the sheet where the data is sent to should be the sheet corresponding to the month in the userform txtbox "today".

    I really hope you can help me.
    Attached Files Attached Files

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: How to define date format in userform

    I would change your cmdguardar_Click() sub to this:

    Please Login or Register  to view this content.
    This code assumes you have already added the 12 months as worksheets, with the sheet names being the UNabreviated month names.

    However, I'm wondering if the language differences is causing a problem. This is the same basic code I'm using for my example, which you said did not work for you.

  5. #5
    Forum Contributor
    Join Date
    04-27-2010
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    115

    Re: How to define date format in userform

    Yeah, you might be right, i'm getting an rutime error 9. even if i wasnīt, this would bring up another issue that i can't resolve. The auto filled txtbox id! i wouldnīt know how to send it to the same sheet that the remaining data...

    Thanks anyway. I think i'll have to try another aprroach.

+ 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