+ Reply to Thread
Results 1 to 2 of 2

Format CSV file based on data and convert to .xls

  1. #1
    Registered User
    Join Date
    06-28-2017
    Location
    Dallas TX
    MS-Off Ver
    2003
    Posts
    1

    Question Format CSV file based on data and convert to .xls

    I have CSV files generated with unknown number of rows, anywhere from 1 to the maximum. The columns will be constant, likely B2 - AO2. I have recorded a macro to do what I want, however, when recording, I can select the existing cells containing data. What I want to do with the raw CSV file:

    1. Select all columns and resize to fit
    2. Starting at B2, select all cells to Rn, Cn, where 'n' is the final row & column containing data (will only be 0 or 1)
    3. Select only the cells with 1 in them, and highlight
    4. Optionally prompt to save as filename.xls

    I'm not a programmer, but can muddle through ok, and identify basic structure. I can share an example if needed, but it's pretty simple and straightforward data.

    Thanks,
    Mark
    Last edited by 6StringJazzer; 06-28-2017 at 05:16 PM. Reason: Better title

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Format CSV file based on data and convert to .xls

    I normally do not respond to posts that don't have a sample file attached since it's too much work (normally) to recreate the issue or requirement. In other words, if you attach a sample file, it is more likely that someone will respond.

    Having said that, I just happened to have a CSV file laying around so I went forth and VBA'ed.

    The odd thing about this spreadsheet is that it is merely a container for the VB code and except for some parameters you supply, doesn't get involved in the program at all.

    Cell B1 contains the path name to where the CSV file exists.
    Cell B2 contains the name of the CSV file.
    Cell B3 contains the name of the output file.

    If cell B3 is blank, then the program creates a name based on the CSV file name. So XYZ.csv gets written to XYZ.xls.

    Some of this programming (autofit and conditional formatting) was done by recording macros and modifying them.

    In answer to one of your questions, note the computation of LRowC and LColC. These are "standard" formulas for getting the last row in a column and the last column on a row.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

+ 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. Quick Help w Macro
    By jkhoury1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2017, 03:17 PM
  2. Help creating quick macro - thanks!
    By skipper24 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-06-2015, 07:26 PM
  3. quick sort macro
    By LMHmedchem in forum Excel General
    Replies: 9
    Last Post: 03-26-2014, 05:26 PM
  4. [SOLVED] Quick question about automatic row deletion (should be very quick and easy!!)
    By poptart141 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-09-2013, 12:56 PM
  5. Need Quick Macro Help!
    By bxc2739 in forum Excel General
    Replies: 2
    Last Post: 04-24-2006, 03:32 PM
  6. Quick question - quick answer about assigning shortcut keys
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2005, 06:05 AM
  7. quick lil macro
    By ChasePenelli in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2005, 08:05 PM

Tags for this Thread

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