I leave this very little one...

mariomenc

New Member
Joined
Aug 25, 2005
Messages
26
I know this question for all of you is real easy, I want to run a macro when I close the file. I know this is possible and I'll like to somebody tell me how.


Thanks
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

nbrcrunch

Well-known Member
Joined
Jan 1, 2003
Messages
2,062
In the code I wrote below, I am prompted to make a backup copy. The code resides in "ThisWorkbook"

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Msg = "Would you like to make a backup of this file?"
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbYes Then
FName = "C:\My Documents\HomeActg\" & ThisWorkbook.Name
ThisWorkbook.SaveCopyAs FName
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,450
Messages
5,572,181
Members
412,447
Latest member
immy
Top