SOLVED

need help with saving a sheet to a new workbook csv

Copper Contributor

i found this code 

 

nomFichier = ActiveWorkbook.Path & "\" & "_" & ActiveSheet.name & Format(Now, "_yyyymmdd")

'ActiveSheet.Copy
'ActiveWorkbook.SaveAs nomFichier
Application.DisplayAlerts = False
wbNew.SaveAs nomFichier & ".csv", xlCSVUTF8 'new way

Application.DisplayAlerts = True

 

it almost does what i need (i mean it grabs my sheet and saves it into csv format 

but for some reason it also renames my sheet in my current workbook and i do not want that :(

 

all i need it to do is to grab my sheet and save it to a new workbook in CSV format utf-8

 

thank you for any help

4 Replies

@Slyfox6915 

    nomFichier = ActiveWorkbook.Path & "\" & "_" & ActiveSheet.Name & Format(Now, "_yyyymmdd")
    ActiveSheet.Copy
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs nomFichier & ".csv", xlCSVUTF8
    ActiveWorkbook.Close SaveChanges:=False
    Application.DisplayAlerts = True
will that just close my workbook ?
best response confirmed by Slyfox6915 (Copper Contributor)
Solution

@Slyfox6915 

No,

It copies the active sheet to a new workbook.This new workbook is now the active workbook.

This will be saved as a .csv file and then closed. You are left with the original, unchanged workbook.

Thank you so much
1 best response

Accepted Solutions
best response confirmed by Slyfox6915 (Copper Contributor)
Solution

@Slyfox6915 

No,

It copies the active sheet to a new workbook.This new workbook is now the active workbook.

This will be saved as a .csv file and then closed. You are left with the original, unchanged workbook.

View solution in original post