+ Reply to Thread
Results 1 to 6 of 6

Pasting CSV data in workbook with date formating

  1. #1
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Pasting CSV data in workbook with date formating

    Hi guys,

    I've run into an issue I can't resolve.

    I'm copying data from a csv file and pasting in to a workbook. The data is in dd/mm/yyyy format and when I copy the data I'm setting local:=true

    I can physically paste the data into a workbook at this stage manually and the date data is formatted correctly ie dd/mm/yyyy, however if I record that same manual process as a macro and rerun the macro it pastes the date data in mm/dd/yyyy format.

    I've tried formatting the column of data before copying, after copying but it's not a formatting issue (I think) as the data is in text form when I copy it (or is it).

    This is the line I'm using to paste the data

    Please Login or Register  to view this content.
    Do I need to add something to that ?

    Thanks for any help in advance
    Happy with my advice? Click on the * reputation button below

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Pasting CSV data in workbook with date formating

    Hi Crooza,

    When we live outside the USA, dates cause lots of problems which the MS programmers seen reluctant to address.

    I believe that when you OPEN the file in your macro, if you code something like:
    Please Login or Register  to view this content.
    you will get what you want. I know I've dealt with it several years ago, but can't remember what I did, so I used Google to remind me.

    I discovered that by setting Local = true uses the local machines date format rather than assuming mdy so in countries such as Australia (dmy) it'll change the behaviour of Open()

    I hope this helps, please let me know!

    Regards,

    David

    If this has been helpful
    - Please click on the *Add Reputation button at the bottom left.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  3. #3
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Pasting CSV data in workbook with date formating

    David

    Thanks. Yes I've set Local:=true and that gets the data in the correct format. As I stated if I copy I can paste manually and it pastes in the correct format but if I use VBA to paste it reverts to the old format!!

    It's driving me crazy.

  4. #4
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Pasting CSV data in workbook with date formating

    I think I remembered what I did!

    I wonder if you could work on the CSV data with your macro.

    When you open the CSV file, use VBA to change the format of the date column(s) to General - then do your copy and paste steps, and in your new sheet, format the dates back to the format you want.

    I hope this helps, please let me know!

    Regards,

    David

    If this has been helpful
    - Please click on the *Add Reputation button at the bottom left.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  5. #5
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Pasting CSV data in workbook with date formating

    Mate

    Thanks. That was all it needed. I hate working with date fields. You've saved me some headaches.

    Well done

  6. #6
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Pasting CSV data in workbook with date formating

    Thanks for the Rep, Crooza. I share your opinion of date fields! Happy I was able to help. Simple solution, but it works!

    David

+ 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. Copy Data of today's date from cell and pasting it into another workbook
    By sachit08 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-16-2015, 06:45 PM
  2. [SOLVED] Pasting to another existing workbook based on date criteria
    By smashthegas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-14-2015, 11:17 AM
  3. [SOLVED] The workbook you are pasting to uses a different date system
    By Nitefox in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 14
    Last Post: 09-21-2013, 10:10 PM
  4. Change active cell when pasting date from another workbook
    By JBlam in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2013, 04:33 AM
  5. Filtering in another workbook, copying filtered data and pasting in source workbook
    By saadtariq in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2012, 12:55 PM
  6. Replies: 0
    Last Post: 08-11-2011, 01:23 AM
  7. Formating/ Pasting
    By Shajantha321 in forum Excel General
    Replies: 2
    Last Post: 05-05-2008, 11:39 AM

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