ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to simply export a single sheet to a new .csv file? (https://www.excelbanter.com/excel-programming/381702-how-simply-export-single-sheet-new-csv-file.html)

[email protected]

How to simply export a single sheet to a new .csv file?
 
Hi,

I'm sure my problem is not that difficult but it seems unique as my
searches haven't come up with anything similar. I have an excel file,
test1.xls and I want to take sheet2 specifically and export it into C:
and call the file that contains it test1.csv. In the module, I have
something like this:


Sub exportcsv()


Dim sheet2 As Worksheet



For sheet2 In ActiveWorkbook.Worksheets
sheet2.Copy
With ActiveSheet
.Parent.SaveAs Filename:="C:" & .test1, _
FileFormat:=xlCSV
.Parent.Close savechanges:=False
End With

Thanks for any suggestions...

End Sub


Dave Peterson

How to simply export a single sheet to a new .csv file?
 
Option Explicit
Sub Testme()
worksheets("sheet2").copy
With ActiveSheet
.Parent.SaveAs Filename:="C:\test1", _
FileFormat:=xlCSV
.Parent.Close savechanges:=False
End With
End Sub


wrote:

Hi,

I'm sure my problem is not that difficult but it seems unique as my
searches haven't come up with anything similar. I have an excel file,
test1.xls and I want to take sheet2 specifically and export it into C:
and call the file that contains it test1.csv. In the module, I have
something like this:

Sub exportcsv()

Dim sheet2 As Worksheet

For sheet2 In ActiveWorkbook.Worksheets
sheet2.Copy
With ActiveSheet
.Parent.SaveAs Filename:="C:" & .test1, _
FileFormat:=xlCSV
.Parent.Close savechanges:=False
End With

Thanks for any suggestions...

End Sub


--

Dave Peterson

[email protected]

How to simply export a single sheet to a new .csv file?
 
Wow, that worked! Thanks for the super quick response!



All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com