ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to export excel sheet to CSV (https://www.excelbanter.com/excel-programming/445335-how-export-excel-sheet-csv.html)

geniusideas

How to export excel sheet to CSV
 
Hi guys,

I just to export excel sheets to CSV with one click button then user
will prompt to save to any folder they like, key in file name and
done. Please help with VBA code. Thanks

merjet

How to export excel sheet to CSV
 
The following works in Excel 2003 and is a macro, but it should help.

Sub SaveSheetToFile()
str1 = ThisWorkbook.Name
Workbooks(str1).ActiveSheet.Cells.Select
Selection.Copy
str2 = InputBox("Enter folder name. e.g. c:\MyFiles\")
str3 = InputBox("Enter file name. e.g. Book1")
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs Filename:=str2 & str3 & ".csv", FileFormat:=
_
xlCSVMSDOS, CreateBackup:=False
ActiveWorkbook.Close True
End Sub



All times are GMT +1. The time now is 03:06 AM.

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