Hello,
I'm using code to generate individual CSV files for each worksheet of a single workbook. However, these individual CSV files that are generated need to be within UTF-8 format. Could someone assist me with modifying this code for those purposes? I greatly appreciate it!
Thanks!
I'm using code to generate individual CSV files for each worksheet of a single workbook. However, these individual CSV files that are generated need to be within UTF-8 format. Could someone assist me with modifying this code for those purposes? I greatly appreciate it!
Thanks!
Code:
Sub Create_Files()
Dim WS As Excel.Worksheet
Dim relativePath As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
' Store current details for the workbook
relativePath = ThisWorkbook.Path
For Each WS In ThisWorkbook.Worksheets
Sheets(WS.Name).Copy
ActiveWorkbook.SaveAs Filename:=relativePath & ThisWorkbook.Name & "-" & WS.Name & ".csv", FileFormat:=xlCSV
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
Next
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True
' Temporarily turn alerts off to prevent the user being prompted
' about overwriting the original file.
End Sub