View Full Version : Exporting A Worksheet To A CSV File / Save Workbook As CSV File
jffryjsphbyn
06-20-2013, 12:12 PM
Hello,
I would like to ask help for the vba code to export a single worksheet to a csv file. And the user will save it manually. I mean, User will be the one to put the file name, and look for the destination of the file where to be saved.
Thank you in advance,
Jeffrey
Excel Fox
06-20-2013, 01:28 PM
This will only work for the first sheet of your workbook.
Sub SaveAsCSV()
ActiveWorkbook.SaveAs Application.GetSaveAsFilename(, "Comma Seperated Value File (*.csv), *.csv"), xlCSV
End Sub
jffryjsphbyn
06-20-2013, 02:46 PM
It shows an error " Object Required "
Here's my code.
Sub export()
Application.DisplayAlerts = False
sFileName = "CLASSIFIED.csv"
Sheets("CLASSIFIED").Range("A1:AN1000").Copy
Set WB = Workbooks.Add
With WB
.Title = "Classified"
.Sheets(1).Select
ActiveSheet.Paste
ActiveWorksheet.SaveAs Application.GetSaveAsFilename("", "Comma Seperated Value File (*.csv), *.csv"), xlCSV
End With
Application.DisplayAlerts = True
End Sub
bakerman
06-20-2013, 04:09 PM
Sub export()
Application.DisplayAlerts = False
Sheets("CLASSIFIED").Copy
With ActiveWorkbook
.Title = "Classified"
.SaveAs Application.GetSaveAsFilename("CLASSIFIED", "Comma Seperated Value File (*.csv), *.csv"), xlCSV
.Close True
End With
Application.DisplayAlerts = True
End Sub
Excel Fox
06-20-2013, 04:25 PM
A sheet doesn't have a SaveAs method. Why would you change the SaveAs method I used for the workbook, on to a worksheet? I'm refering to Post #3 above.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.