+ Reply to Thread
Results 1 to 5 of 5

Date formats don't retain their format?

  1. #1
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Date formats don't retain their format?

    Hello everyone!

    I select a range of cells with dates in them and I set their formats to types like this "14/03/01".

    But this is the format I want: Day/Month/Year >>> 11/02/2018

    But no matter what I try some cells display correctly and some just won't ???

    I don't know what else to try anymore!!!

    Please view image... as you can see that there is some code writing dates in the range of date cells and again some will display correctlyt and some display in the non desired date format???

    Any help would be greatly appreciated!

    Rn
    Attached Images Attached Images
    Last edited by RustyNail; 02-09-2019 at 05:17 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Date formats don't retain their format?

    Cant really see the code, the pic is a little small.

    But try Custom format dd/mm/yy;@
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Date formats don't retain their format?

    In the Watch window, all of the values in NoOfClaimsPerWeek are surrounded by double quotes -- suggesting they are text strings and not real numbers/dates. I cannot test what happens when VBA writes a "date stored as text" into an Excel cell, but I notice that all of your dates in the picture spreadsheet cells are left justified -- default for text string where numbers (and dates are really just numbers) default to right justified.

    I might test this with an ISTEXT() function. Enter =ISTEXT(X6) into X14 and copy down and across. This will tell you which of those dates (if any) are text strings and which are real date serial numbers.

    Assuming that at least some of those dates are really text, the solution I see is to go back to the either the point where the data are read into NoClaimsPerWeek and make sure the date "field" is entered into VBA as a date serial number or go back to where the date string is written to Excel and make certain that it is converted to the correct date serial number when written to the spreadsheet. If the dates are entered into the cell as proper date serial numbers, then they will respond to the desired number format.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Contributor
    Join Date
    03-07-2013
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    274

    Re: Date formats don't retain their format?

    Hey guys sorry for the delay....

    "but I notice that all of your dates in the picture spreadsheet cells are left justified"

    that pretty much solved it !

    Thanks so much
    rn

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Date formats don't retain their format?

    Thanks for the feedback

+ 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] Two date-arrays with different formats. How to get same format.
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2017, 07:44 AM
  2. Date Format Formulam - Mixture of date formats and seperators
    By kp1983 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 02:12 PM
  3. Replies: 2
    Last Post: 06-02-2015, 08:42 AM
  4. [SOLVED] mixed date formats in s/s, how to format
    By cal_chica in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-16-2014, 06:22 PM
  5. Retain date format for input entered as date
    By Chippi in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2014, 07:20 AM
  6. How to retain date format when using ActiveCell.Offset().Value
    By ST4RCUTTER in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2007, 04:44 PM
  7. [SOLVED] Retain date format in cell
    By Jan 2HW in forum Excel General
    Replies: 1
    Last Post: 08-09-2006, 02:34 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