+ Reply to Thread
Results 1 to 4 of 4

Cell date format refresh

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Cell date format refresh

    Hi all,

    I wonder if someone could help please?

    In the attached I have a list of dates. The dates are the first date of each month but are not formatted correctly.
    If I am doing this manually then I would change the format of my cells to date. This wouldn't be enough though and it would only change if I click in and out of the cell. As I can have thousands of rows I would normally use text to columns to refresh all cells at once and get my data in the correct cell format of a date.

    How can I do the same in code?

    When I try to replicate this in code using the attached data, it works but my dates end up wrong. Instead of reading the first date of every month it switches the date and month round so that all dates are in January.

    Any help is appreciated. File attached.
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Cell date format refresh

    Using your posted workbook...
    Try this

    • Select the single-column range of "dates"
    • Data.Text-to-columns...Click: Finish
    That will convert the text to actual dates.


    EDITED TO INCLUDE THIS COMMENT:
    Since I'm on the other side of the pond...I needed to indicate to Excel that text-dates are d/m/y
    • Select the single-column range of "dates"
    • Data.Text-to-columns...Click: Next...Click: Next
    ...Check: Date....DMY...Click: Finish



    Is that something you can work with?
    Last edited by Ron Coderre; 09-09-2015 at 09:52 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Cell date format refresh

    Thanks for the help Ron, however, if the dates are in the correct format and the format has been applied (cells clicked into) already, then running the macro on this will change the dates switching the month and days. If the format has not been applied, then this does work.

    I have attached an example with the macro in the workbook where the first two columns have not got the formats applied to them but the third one has.

    I need it to run automatically on all columns, therefore is there a way I can differentiate between the columns where the formats have been applied and haven’t so that the dates don’t change on the columns that are already correct?

    File is attached again. Thanks in advance. Dates Example.xlsm

  4. #4
    Forum Contributor
    Join Date
    03-24-2009
    Location
    London, UK
    MS-Off Ver
    Excel 2007
    Posts
    178

    Re: Cell date format refresh

    Just to say that I found a work around to this problem. On 3 unused columns to the right hand side I used a formula to show date, the next column for month and the next one year and copied and pasted as values.
    I was then able to put them back together again to get the date in the format required.

    Thanks for the help.

+ 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. Macro to refresh Essbase data sets, display refresh date?
    By nellaneb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2014, 03:59 PM
  2. Missing date format after refresh pivot table
    By verlax in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-05-2014, 07:53 AM
  3. Replies: 2
    Last Post: 07-09-2014, 01:38 PM
  4. Replies: 1
    Last Post: 11-01-2012, 10:37 AM
  5. Date format refresh revisited
    By kmalysiak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2011, 05:47 AM
  6. Pivot table - cell format to remain the same when refresh
    By mingali in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-15-2010, 12:01 PM
  7. Date in cell to update upon Pivot Table refresh
    By chris46521 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-17-2006, 06:02 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