Forum Discussion

Slyfox6915's avatar
Slyfox6915
Copper Contributor
Jul 20, 2022
Solved

need help with saving a sheet to a new workbook csv

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

  • 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.

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
      • HansVogelaar's avatar
        HansVogelaar
        MVP

        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.