Macro to Close and save all changes

S

Souljah

Could anyone write me a macro to close the spreadsheet and prompt t
save changes? I need to link it to a button on my spreadsheet.

thanks for any hel
 
D

DENNIS

Surely just clicking the X at the top left will produce
this.

However, if you want a button to do this then create the
button and in the code put ThisWorkBook.Close
If changes have been made then you will be prompted to
save them.

hth
 
C

Charles

Greg,

Try

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
MsgBox "Be Sure You Save Before you close this Program"
ActiveWorkbook.Save
End Sub


Your Friend Charles

Ps it on your copy I sent you
 
D

Dave Peterson

You'd want to use "Application.Quit" in your code.

But I sometimes have multiple workbooks open at one time. It might be nicer to
just let the user close excel.
 
Top