?
Solved

Saving Multiple Worksheets as Separate CSV Files to Specific Location

Posted on 2015-02-06
3
Medium Priority
?
98 Views
Last Modified: 2016-02-10
The current code I have is working, however how do I add a specific location that I want the csv files saved to?

The location is "H:\Touchstone"

Sub SAVEASCSV()
Dim ws As Worksheet, newWb As Workbook
Application.ScreenUpdating = False
For Each ws In Sheets(Array("CONTRACT", "LOC", "REINS"))
   ws.Copy
   Set newWb = ActiveWorkbook
   With newWb
      .SAVEAS ws.Name, xlCSV
            .Close (False)
   End With
Next ws
Application.ScreenUpdating = True

End Sub

Open in new window

0
Comment
Question by:kateebebe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Simon earned 2000 total points
ID: 40594162
Sub SAVEASCSV()
Dim ws As Worksheet, newWb As Workbook, savePath as string
savePath=H:\Touchstone\" 'Variable to store the path to the folder you want to save files in.
Application.ScreenUpdating = False
For Each ws In Sheets(Array("CONTRACT", "LOC", "REINS"))
   ws.Copy
   Set newWb = ActiveWorkbook
   With newWb
      .SAVEAS savePath & ws.Name, xlCSV 'Concatenate the path and workbook name
       .Close (False)
   End With
Next ws
Application.ScreenUpdating = True

End Sub

Open in new window

0
 

Author Comment

by:kateebebe
ID: 40594194
That didn't work.  It continues to save in the last place I did a save as csv, but now it renames the saved files as H:\touchstoneContract.csv

ps.  There is a " missing right after the savepath above in your code.
0
 

Author Comment

by:kateebebe
ID: 40594221
It is actually working now.  Sorry.  Your code is correct, just have to add the ".  

Thank you!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question