View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Run macro brfore close

Thanks!

"Jacob Skaria" wrote:

From workbook launch VBE using short-key Alt+F11. On the left treeview for
this project double click 'This Workbook' and paste the code to the code
panel.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Update File?", vbYesNoCancel + vbQuestion, "File Update") _
< vbYes Then Exit Sub
'Run file update code
MsgBox "File Updated"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Al" wrote:

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