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

R

redrosekrs

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
 
D

Dave Peterson

Option Explicit
Sub Testme()
worksheets("sheet2").copy
With ActiveSheet
.Parent.SaveAs Filename:="C:\test1", _
FileFormat:=xlCSV
.Parent.Close savechanges:=False
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top