+ Reply to Thread
Results 1 to 10 of 10

Automate CSV creation with unique file names

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Automate CSV creation with unique file names

    Attached is a small sample of data that I am trying to create individual CSV files with.

    The Sheet "Sample Data" has 3 columns..... of which I have been doing a copy paste (row by row) of columns B and C into the file "sample template" A16 and B16... then doing a copy/paste values of A1:Z12 into a new file, and saving that file as a csv with a title of whatever the value in "Sample Template A16" is. See attached 10001.csv for sample output

    Because eventually this will need to happen for over 200 different items, it is going to be a long and slow process to do it manually, and I was trying to find a way to automate it.

    Is there a Macro that I can use to do this same thing? Sample Data and Sample Template do not necessarily need to be separate files if that makes what Im trying to do easier? Thank you in advance for your help
    Attached Files Attached Files

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Automate CSV creation with unique file names

    Add a module and paste in this code.
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Automate CSV creation with unique file names

    To which file do I add this module to??? Does it matter?

  4. #4
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Automate CSV creation with unique file names

    Sorry... stupid question... I tried it out and it is ALMMMMMOOOSSSSTTTT there.

    In the original Template file I am using a concatenate naming convention on the items in Column A to add in the 00-01 pcf, 01-02 pcf, etc....

    The VB code is not utilizing that part of it, so the names for column A do not come out correct.... is there a way to fix that part of it???

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Automate CSV creation with unique file names

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Automate CSV creation with unique file names

    I just assumed that the sample data would be changing and so was trying to prevent chaving to edit the template sheet. But as usual, I was thinking too much,

    Here's the adjusted code.

    Please Login or Register  to view this content.

  7. #7
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Automate CSV creation with unique file names

    Thank you so very much! One of the ways that I learn is by looking at code and trying to figure it out... how to change it, and what the changes will do. This has helped me understand a lot more on the VB side.

    One question that I have is, if the initial sample data size were to grow to say 100 lines, 1000 lines, etc Is the change that would need to occur be in the
    Please Login or Register  to view this content.
    part? And just update that 26 to however many rows there are without the header row included???

  8. #8
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Automate CSV creation with unique file names

    It's the line before.

    I is rows, J is Columns.

    If you want to make that dynamic as well, you'll have to explain where the suffix of the Name comes from.

    I would move B16 to a variable so we could use a LastRow function to make the template dynamic.

  9. #9
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Automate CSV creation with unique file names

    Here is an updated file that moved the B16 to A1 for dynamic template.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Automate CSV creation with unique file names

    Thank you again for the info. I will play around with it and let you knowing I have any other questions. Thank you for adding notes to the code so that I can learn from it as well. Truly awesome.

+ 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. How to Automate the Creation of PPT
    By balajisx in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2017, 10:58 AM
  2. Excel file creation dates do not match the windows creation date.
    By alexthapyro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2011, 12:14 PM
  3. [SOLVED] Would Like to Automate Batch File Creation and Text FIle Import
    By socrtwo in forum Excel General
    Replies: 2
    Last Post: 08-18-2006, 11:00 AM
  4. [SOLVED] automate creation of sheets in excel
    By Daniel in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. [SOLVED] automate creation of sheets in excel
    By Daniel in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. [SOLVED] automate creation of sheets in excel
    By Daniel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2005, 06:05 PM
  7. [SOLVED] HOW DO I AUTOMATE CREATION OF JOB SHEETS?
    By bobby smith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2005, 08:05 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