+ Reply to Thread
Results 1 to 7 of 7

Recorded macro for date format is different with the recording process

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Recorded macro for date format is different with the recording process

    I macro record when I do this manually :
    select a cell with a date value
    custom format it to "d/mm/yyyy"
    stop the macro.

    The resulting code is :
    Selection.NumberFormat = "d\/mm\/yyyy"

    I thought the result would be:
    Selection.NumberFormat = "d/mm/yyyy"
    The other thing is when the manual custom format process is "dd-mm-yyyy",
    the resulting code is :
    Selection.NumberFormat = "d/mm/yyyy"
    Maybe someone can explain it to me why the result is like that ?
    Thank you in advanced.

    My computer Short Date setting is : dd-MMM-yy
    Last edited by karmapala; 06-24-2020 at 02:43 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Recorded macro for date format is different with the recording process


    Maybe 'cause of the Windows Regional settings …

  3. #3
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Recorded macro for date format is different with the recording process

    Thanks for the answer, Marc.

    This made me think if for example I'm helping someone where the code need a date format,
    then the result seen in my computer may be different than in his computer .

    Because within my computer :
    Selection.NumberFormat = "d/mm/yyyy"
    or
    Selection.NumberFormat = "d-mm-yyyy"
    gives the same display in the cell, which is :
    25-12-2020

    I wonder if I write :
    Selection.NumberFormat = "d\/mm\/yyyy"
    No matter is the regional setting, the result in the cell will be:
    25/12/2020

    Thanks once again, Marc
    Last edited by karmapala; 06-24-2020 at 02:45 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Recorded macro for date format is different with the recording process

    It is therefore a very good date to test with.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Recorded macro for date format is different with the recording process


    karmapala see one month ago in this thread

  6. #6
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Recorded macro for date format is different with the recording process

    Marc,

    Wow, I never thought that the same thing is also happen with nankw83 .
    I'm sorry that I didn't do search first in this forum.

    Yes, you are right then it's because my Windows Regional Setting,
    as I have in my computer is with minus sign : dd-MMM-yy.

    But still I think that it can leads to a confusion, if I write :
    Selection.NumberFormat = "d/mm/yyyy"
    although seeing in my computer has a correct display ---> 25/12/2020 (after change the Windows Regional Setting),
    but if the other computer's Windows Regional Setting is dd-MMM-yy, then the display is 25-12-2020.

    Thank you once again for sparing your time to search the one month ago link, Marc.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Recorded macro for date format is different with the recording process


    You're welcome ! One month ago I had never met this case …

+ 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] Recorded macro does other than while recording
    By HvLbeheer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2017, 11:22 AM
  2. Add If condition to a code recorded by Macro recording function in Excel
    By Emma_B in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-29-2014, 01:36 AM
  3. Recorded Macro changing date format
    By cindywylie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2014, 03:56 PM
  4. [SOLVED] How to revised macro code to repeat the recorded task without recording several times?
    By reimar_rem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2013, 01:34 AM
  5. Recording Macro to generate scatter plot: Plot from Macro different from recorded.
    By VaPiano in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-09-2012, 05:41 AM
  6. [SOLVED] Date format when using Text Input Wizard and recording a macro
    By Dave H. in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2006, 12:55 PM
  7. Recorded Macro to Copy Format
    By Lilbit in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-10-2006, 05:45 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