Hi everyone!
I have this macro and I want to run it when the user closes the file. How can I put it running automatically?
Thanks in advance for your help.
I have this macro and I want to run it when the user closes the file. How can I put it running automatically?
VBA Code:
Private Sub Workbook_BeforeClose(ByVal SaveAsUI As Boolean, Cancel As Boolean)
last_row_ose = get_last_row("S1", "I")
Worksheets("S1").Range("I12:O" & last_row_ose).ClearContents
last_row_pa = get_last_row("S2", "C")
Worksheets("S2").Range("C9:G" & last_row_pa).ClearContents
last_row_pro = get_last_row("S3", "C")
Worksheets("S3").Range("C7:AZ" & last_row_pro).ClearContents
last_row_pr = get_last_row("S4", "C")
Worksheets("S4").Range("C8:AZ" & last_row_pr).ClearContents
last_row_to = get_last_row("S5", "C")
Worksheets("S5").Range("C6:H" & last_row_to).ClearContents
End Sub
Thanks in advance for your help.