Reputation: 333
I would like to export a sheet as a csv into a new dir but it doesn't work using the SaveAs method of the worksheet.
When I use SaveAs, I "lose focus" of my current workbook and the current workbook is now the csv file (in the new dir). I would like to export the sheet and keep the focus on the current workbook.
Upvotes: 0
Views: 1828
Reputation: 2859
This will work for you
Sub SaveCSV()
Sheet1.Copy ' Change to whatever sheet you want to copy
ActiveWorkbook.SaveAs "MyFileCSV.csv", xlCSV
ActiveWorkbook.Close False
ThisWorkbook.Activate
End Sub
Upvotes: 3