View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Umlas[_3_] Bob Umlas[_3_] is offline
external usenet poster
 
Posts: 320
Default Run macro brfore close

In the VBE, double-click the ThisWorkbook in the Project window, enter this
code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
update 'runs your macro
End Sub

Bob Umlas
Excel MVP

"Al" wrote in message
...
Hello
I would like to run this code before the file is closed.

Sub Update()

Msg = "Update File?"
Title = "File Update"
Response = MsgBox(Msg, vbYesNoCancel + vbQuestion, Title)
If Response = vbNo Then
Exit Sub
End If

If Response = vbCancel Then
Exit Sub
End If

Run file update code

MsgBox "File Updated"


End Sub

How do I do this?
Thanks