Save one worksheet from a workbook to a new .csv file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

In code, how can I save one specific worksheet from a workbook with many
worksheets to a new .csv file. I've looked at the SaveAs Method in Help but I
don't see the answer there. Any help would be appreciated.
 
Hi Chuck

Try this for the activesheet

Sub ActiveSheet_CSV_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String
strdate = Format(Now, "dd-mmm-yy h-mm-ss")
Fname = "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".csv"
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlCSV
.Close False
End With
Application.ScreenUpdating = True
End Sub
 
Hi Ron,

That works perfectly.

Thanks for the quick response.
--
Thanks.
Chuck M.


Ron de Bruin said:
Hi Chuck

Try this for the activesheet

Sub ActiveSheet_CSV_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String
strdate = Format(Now, "dd-mmm-yy h-mm-ss")
Fname = "C:\Part of " & ThisWorkbook.Name _
& " " & strdate & ".csv"
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlCSV
.Close False
End With
Application.ScreenUpdating = True
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

Back
Top