Export Areas

  • Thread starter Michael MacLachlan
  • Start date
M

Michael MacLachlan

Is it possible to export certain areas from Sheets in a workbook
automatically to single .CSV Files with the name of the sheet ?
E.G.: The Range A:5 - Z:89 for the Sheets named Argentina, Austria,...
should produce .CSV Files named : Argentina.csv, Austria.csv ......
 
V

Vikrant Vaidya

Start recording a macro and do it manually once. then next time just run that
macro. You will find record macros in Tools>Macro
 
D

Dave Peterson

How do you know which worksheets to copy?

If you can copy all the worksheets in the workbook, then you could use code
like:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim newWks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
'or use this for your selected sheets
'For Each wks In ActiveWindow.SelectedSheets
Set newWks = Workbooks.Add(1).Worksheets(1)
wks.Range("a5:z89").Copy _
Destination:=newWks.Range("a1")
With newWks
Application.DisplayAlerts = False
.Parent.SaveAs Filename:="C:\WINDOWS\TEMP\" & wks.Name, _
FileFormat:=xlCSV
Application.DisplayAlerts = True
.Parent.Close savechanges:=False
End With
Next wks

End Sub

If you have to ignore some of the worksheets, maybe you could group the sheets
(click on the first worksheet tab and ctrl-click on subsequent), then uncomment
the activewindow line and comment the activeworkbook line.

For Each wks In ActiveWorkbook.Worksheets
'or use this for your selected sheets
'For Each wks In ActiveWindow.SelectedSheets
 
Top