Forum Discussion
lnmlilo
Nov 14, 2024Copper Contributor
VBA: Save file as .csv with sequential numbering
Good day Community, I am trying to save one sheet from a macro-enabled file as a .csv document. I will need to save it every month so each month I would like to save the file with a new number (e...
Nov 15, 2024
Due to sandboxing on Mac, you probably need to grant access to the folder where you want the CSV's to be saved before it will work. Please take a look at this article:
Mac - Grant Access to Multiple files (Microsoft Help)
When saving a sheet as CSV, I like to first make a copy of the sheet in a new book so I don't need to worry about any unwanted changes happening to the source file. To do that, I use the following lines:
'Copy the active sheet to a new workbook.
ActiveWorkbook.ActiveSheet.Copy
Set newsheet = ActiveSheet
'Convert all cells to values, if necessary
newsheet.UsedRange.Value = newsheet.UsedRange.Value
Then you can save the 'newsheet' workbook and close it without anything happening to the source file.