LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default VBA loop to create named .csv files for all worksheets and workbooks in a folder

This code OK in 2007 for one workbook only.

You will have to add a loop to go through all workbooks in the folder.

Sub Make_New_Books()
Dim w As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
FileExtStr = ".csv": FileFormatNum = 6
For Each w In ActiveWorkbook.Worksheets
w.Copy
With ActiveWorkbook
.SaveAs Filename:=ThisWorkbook.Path & "\" & ThisWorkbook.Name _
& "_" & w.Name & FileExtStr
.Close
End With
Next w
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub


Gord

On Sat, 5 May 2012 11:24:31 +0000, KQBats
wrote:


Hi all

I don't have a great deal of experience with VBA, but can usually muddle
my way through. I have drawn a blank with the following, however.

I have a folder containing multiple excel workbooks, all of which are of
the same structure. The workbooks contain multiple work sheets. I want
to write a macro that saves each worksheet within each workbook as a
separate .csv file that is named "NameofWorkBook_NameofWorkSheet". These
would all be saved into the existing folder.

I have been reading threads on similar topics and trying to meld them
together, but the best I have been able to do is save each worksheet
within a single workbook as the name of the worksheet. I am using Excel
2010. Any assistance with sample code, or directing me to where this has
previously been addressed would be most appreciated.

Thanks in advance...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to Export All Worksheets from All Workbooks in Folder to Separate FIles not as CSV Files socrtwo Excel Programming 2 October 30th 06 12:46 AM
Loop through folder of workbooks and add rows FIRSTROUNDKO via OfficeKB.com Excel Worksheet Functions 0 August 10th 06 07:50 PM
Loop thru All Files in a Folder Juan Sanchez Excel Programming 3 July 5th 04 06:38 PM
Loop through all files in a folder Fred Smith Excel Programming 4 June 7th 04 12:30 AM
Loop through workbooks in a folder and return the value of cell M43 RockNRoll[_2_] Excel Programming 1 January 21st 04 07:46 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"