I have a spreadsheet xlsm "My_workfile1", I would like to Save As this file like "My_final_workfile_1.xlsm".
I would like to hold all data in "My_final_workfile_1" and have the cells C4,C6,C7,C11,C12 in initial file "My_workfile1" empty after closing.
My code is:
Sub logFormState()
Sheets("1 - Feuille de Suivi ").Range("C4") = ""
Sheets("1 - Feuille de Suivi ").Range("C6") = ""
Sheets("1 - Feuille de Suivi ").Range("C7") = ""
Sheets("1 - Feuille de Suivi ").Range("C11") = ""
Sheets("1 - Feuille de Suivi ").Range("C12") = ""
End Sub
Public Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Name = "My_workfile1" Then
Call logFormState
End If
End Sub
But Me.Name function doesn't work. I'm wondering if my code is correct.
Thank you for your help!