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
Solved

Saving Multiple Worksheets as Separate CSV Files to Specific Location

Posted on 2015-02-06
3
95 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
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Simon earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Excel Multi Sheet Formula 13 32
Getting rid of #VALUE! 7 22
A Table within a User Form 24 42
Excel Formula for Commission Structure 2 17
Modern/Metro styled message box and input box that directly can replace MsgBox() and InputBox()in Microsoft Access 2013 and later. Also included is a preconfigured error box to be used in error handling.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
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…

856 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