+ Reply to Thread
Results 1 to 9 of 9

Export multiple (specific) worksheets to CSV files in a specified directory

  1. #1
    Registered User
    Join Date
    08-20-2015
    Location
    America
    MS-Off Ver
    2016
    Posts
    4

    Export multiple (specific) worksheets to CSV files in a specified directory

    I'm new to VBA. I'm trying to do the following but the code isn't quite working as expected -

    1. Export/Copy particular sheets in the workbook (any sheet name that contains "Upload") to a particular file directory.

    2. I don't want these worksheet names to change nor the workbook name to change.

    3. The file-name is consistent for each worksheet, so it would be okay to replace the files in the directory whenever I run the macro. Its okay to have a dialog box that asks if I'm sure I want to replace each of the files.

    4. I don't want the newly created CSVs or any other file to open.
    --

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-20-2015 at 11:54 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    'Sheets to CSVs
    Here's a macro for exporting all sheets in an Excel file each to their own CSV file.
    Sheets to CSVs
    Last edited by JBeaucaire; 12-26-2019 at 04:11 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-20-2015
    Location
    America
    MS-Off Ver
    2016
    Posts
    4

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    Thank you! However, instead of every worksheet, how would I only copy selected sheets that contain the word "upload"?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    Please Login or Register  to view this content.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    08-20-2015
    Location
    America
    MS-Off Ver
    2016
    Posts
    4

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    Quote Originally Posted by JBeaucaire View Post
    Please Login or Register  to view this content.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Hey thanks! However, the line on "ActiveWorkbook.SaveAs Filename:=fPATH & ActiveSheet.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False" is not able to run smoothly. Could you guide me on how to make it work?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    I just ran the macro in post #4 on a test workbook of my own, no edits, and it saved several CSVs into the noted folder.

    Let's see your edited version, make sure the fPATH has a \ at the end ....

  7. #7
    Registered User
    Join Date
    08-20-2015
    Location
    America
    MS-Off Ver
    2016
    Posts
    4

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    I did include the "\" at the end but for some reason it is still not working. If it helps, I'm using a Macbook. Do I need to input my own information in any parts other than the fPATH?
    Last edited by reghyh; 08-21-2015 at 08:49 PM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    I don't really have much Mac experience. I'm pretty certain Macs don't use \ for path separators, probably colons :

  9. #9
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Export multiple (specific) worksheets to CSV files in a specified directory

    don't work in mac environment as well but here's a link with someone how has mac coding examples
    http://www.rondebruin.nl/mac/section3.htm
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ 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. [SOLVED] Importing specific data from multiple text files in a file directory into excel
    By abat in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-03-2013, 05:26 PM
  2. [SOLVED] Macro to Import Multiple TXT Files into workbook - User to select files/directory
    By saber007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-15-2013, 08:43 PM
  3. [SOLVED] Copy specific files from one directory to another
    By brazil in forum Excel General
    Replies: 2
    Last Post: 03-06-2013, 03:56 PM
  4. Replies: 1
    Last Post: 10-30-2012, 06:34 PM
  5. Save worksheets as csv files in a given directory
    By adam2308 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2011, 03:22 AM
  6. Opening files in specific directory
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2009, 12:34 AM
  7. Copy selected files into a specific directory
    By Wizz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2009, 10:50 AM
  8. [SOLVED] Opening all files located in a specific directory
    By DaSo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2005, 04:06 AM

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