Results 1 to 9 of 9

Thread: Opening Files That Contain Specific Name And Format Certain Columns

  1. #1
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13

    Opening Files That Contain Specific Name And Format Certain Columns

    I have several files which I export as CSV files.

    I would like to have a macro to open all CSV files where the name contains has the word JNL in the file name for eg BR1 JNL june 2013 in folder C:\Journal Templates and to format the values in Col B & C to 2 decimal places (not using thousand seperator)

    Where Col B & C both how zero values, then Row in CSV file to be deleted

    Your assistance in this regard is most appreciated
    Last edited by Howardc; 07-22-2013 at 12:32 PM.

  2. #2
    Member
    Join Date
    Jun 2013
    Posts
    93
    Rep Power
    11
    attach please a source sample file and the final

  3. #3
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13
    Hi Patel

    See attached sample file
    Attached Files Attached Files

  4. #4
    Member
    Join Date
    May 2013
    Posts
    31
    Rep Power
    0
    That is not a good idea. The files would then be Excel files and not CSV files.

    It would be better to format as needed in some other Master file.

  5. #5
    Senior Member
    Join Date
    Apr 2012
    Posts
    193
    Rep Power
    13
    Hi Kenneth

    Thanks for the information. Will format in the master file.

    Regards

    Howard

  6. #6
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    I haven't come across a situation where opening a CSV file and saving it changes the format to non-CSV
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  7. #7
    Member
    Join Date
    May 2013
    Posts
    31
    Rep Power
    0
    When the CSV file is saved with NumberFormat, the values are not saved to the CSV file. The Text property is saved. This means that you get what you see, for the most part. Formatting a cell in Excel does not change the Value property. Sometimes, that may be what you want I guess.

    If that is what you want, we can do that.
    e.g.
    A2 in one file is 1.555. Formatted to two places is 1.56. Saved as a CSV file and reopened, the value of A2 is now 1.56, not 1.555.

    Of course deleting the rows with 0 values in both columns is easily done.

  8. #8
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Saved as a CSV file and reopened, the value of A2 is now 1.56, not 1.555.
    We probably could be saying the same thing, but I am not sure. If you look at the attachment, I've formatted the numbers to 2 decimal places, however, the values still remain as it were.
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  9. #9
    Member
    Join Date
    May 2013
    Posts
    31
    Rep Power
    0
    I only saw 1 or 2 decimal places in the 2nd column. That file and a new one was doing something that my other tests yesterday did not. After I set the formats, saved, closed, and opened, it rounded as I explained yesterday AND removed the NumberFormats. I would have expected that yesterday but it did not happen with your file. Tested on xl2010 xppro.

    Howard, please test what was posted and play with it. If you can live with how it works, we can do what you originally asked.

Similar Threads

  1. Replies: 8
    Last Post: 07-01-2013, 03:52 PM
  2. Macro to copy data in specific Columns
    By Howardc in forum Excel Help
    Replies: 0
    Last Post: 04-19-2013, 10:42 AM
  3. Excel to Excel Data transfer without opening any of the files(source or target)
    By Transformer in forum Excel and VBA Tips and Tricks
    Replies: 14
    Last Post: 08-22-2012, 10:57 AM
  4. Macro for Opening files and copy the contents of the File
    By ravichandavar in forum Excel Help
    Replies: 16
    Last Post: 08-15-2012, 09:17 PM
  5. Opening a Pdf file using VBA
    By littleiitin in forum Excel Help
    Replies: 2
    Last Post: 11-30-2011, 03:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •