Results 1 to 3 of 3

Result of recorded macro is different from hand work

Threaded View

  1. #1
    Registered User
    Join Date
    03-10-2014
    Location
    Czech republic
    MS-Off Ver
    Excel 2010
    Posts
    2

    Result of recorded macro is different from hand work

    Hi all,

    I have csv file with tab delimited fields (see attached blacklist.csv). 3rd and 4th fields are in format dd/mm/yyyy hh24:mi:ss, some fields can be zero. I need to split data to columns and display datetime fields in format dd.mm.yyyy hh:mm:ss.

    OK... open csv in Excel, select column A, press button "Split in columns", select tab as delimiter, choose date format (DMY) for 3rd and 4th field and press OK. Test is splitted into columns, now select columns C and D and select desired format "dd.mm.yyyy hh:mm:ss". Then I select columns A:E and set column widths to fit data in columns. This all is OK and without problems (see attached file Handmade.xlsx).

    But now... Now I record all previous step into macro. There is macro text:

     Columns("A:A").Select
        Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
            :=Array(Array(1, 1), Array(2, 1), Array(3, 4), Array(4, 4), Array(5, 1)), _
            TrailingMinusNumbers:=True
        Columns("A:E").Select
        Columns("A:E").EntireColumn.AutoFit
        Columns("C:D").Select
        Selection.NumberFormat = "dd/mm/yyyy hh:mm:ss"
    Well.... now I copy macro text into clipboard and open blacklist.csv again. Insert button to list and bind it to new macro. Paste text of macro from clipboard. (See attached file blacklist_beforeClick.xlsm). Now click button Btn and voila... some dates remain in previous format, some dates seems to be in desired format, but day and month are swapped. Why are there differences when comparing data made by hand and data made by macro??? compare.jpg This is the same behavior in more computers, some use Czech version of Excel 2010, some use English version. I am really confused. Does somebody know where is a problem?

    Thanks Petr Brant
    Attached Files Attached Files
    Last edited by alansidman; 03-10-2014 at 08:29 AM. Reason: code tags added

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Trying to make a recorded macro work properly
    By Nick12 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2012, 11:56 AM
  2. Help! The recorded Macro does not work for the highlighted
    By lans_bazx in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 09-19-2012, 06:59 PM
  3. Recorded Macro Does Not Work
    By TheColorLavender in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2012, 01:56 AM
  4. Recorded macro doesn't seem to provide expected result
    By Jeroen1000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2009, 06:52 AM
  5. How to alter a recorded macro to work better
    By antonymiller in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2009, 02:53 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