Shutting Down

mrbeanyuk

Board Regular
Joined
Nov 30, 2005
Messages
212
Hi there. I am trying to write a macro that when you click a button the application saves and closes down.

I cant seem to get anywhere with it.

Grateful for some help and where I would put the VB coding in the spreadsheet

Thanks
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
511
Code:
Sub test()
    ActiveWorkbook.save
    ActiveWorkbook.Close
End Sub

place it in this workbook in VBA

hth

N
 

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
If you are placing buttons on the worksheet using the forms toolbar or the drawing toolbar then you can simply right click on the button and go Assign Macro.

Richard
 

neilp

Well-known Member
Joined
Jul 5, 2004
Messages
511
if you have a button on your sheet, right click it and select "assign macro"
from the box that appears select the macro called test. Then when you click on the button in the future, the macro will run

HTH

N
 

Watch MrExcel Video

Forum statistics

Threads
1,114,407
Messages
5,547,774
Members
410,811
Latest member
adustin42
Top