+ Reply to Thread
Results 1 to 8 of 8

Date Formats

  1. #1
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Date Formats

    Hi

    I have a userform which allows data to be entered onto a worksheet. One of the fields (a textbox with the standard calendar control) is the date. When the transaction saves, it correctly saves the date as dd/mm/yyyy using

    ActiveCell.Value = TxtDate.Text

    I also have a form which allows the user to amend a transaction by loading the data onto the form, amend it and save it back to the worksheet.

    The problem is that when it picks up the data and re-saves it, it's resaved in the format mm/dd/yyyy which is a problem because I use the month as one of the categories that users can filter the data by.

    I also have the following line immediately after each time the data is saved from the form to the worksheet:

    Selection.NumberFormat = "dd/mm/yyyy;@"

    Does anybody have any ideas how I can get around this problem? I can send the excel file if you want it....

    Thanks

    Dion
    Last edited by mojo249; 06-05-2009 at 07:36 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Date Formats

    Hello Dion,

    It would help to see all the code. Can you post the workbook for review?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Date Formats

    Hi Leith

    My file is attached. Please forgive my clunky coding - it's only my second attempt at writing a macro....

    TransForm.TxtDate saves the data to the 'Transactions' sheet.

    TransAmendForm will retireve the data (by entering ComboMonth, selecting the month and scrolling through transaction using the CommandNextTrans button) and re-save it (by hitting the CommandSave button).

    Thanks for your help.

    Dion

  4. #4
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Date Formats

    Sorry...try the attachment again.

    Dion
    Attached Files Attached Files

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Date Formats

    Hello Mojo249,

    Which user form has the problem?

  6. #6
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Date Formats

    The problem is with TransAmendForm.

    The problem arrises when TransAmendForm picks up the date from the Transactions sheet (as dd/mm/yyyy) but resaves it as mm/dd/yyyy.

    Regards

    Dion

  7. #7
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Date Formats

    Hi Leith

    Did you have a chance to look at this?

    Dion

  8. #8
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Date Formats

    Hi

    I solved the problem - I forced a ' in front of the date when I saved it onto the worksheet. Not very elegant but it works.

    Dion

+ 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