Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am looking for a way to have a file run a macro when it is being closed
(the user either hits the X or goes File Close). I want the macro to check certain cells and verify if there are values in them. If the cells are blank then I want an message box to come up saying that all cells are not filled in and the file remains open. Any help in this area is appreciated. Thanks Dan |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the beforeclose event.
See Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Regards, Tom Ogilvy "More Macro Help Needed" wrote in message ... I am looking for a way to have a file run a macro when it is being closed (the user either hits the X or goes File Close). I want the macro to check certain cells and verify if there are values in them. If the cells are blank then I want an message box to come up saying that all cells are not filled in and the file remains open. Any help in this area is appreciated. Thanks Dan |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi
put this in the workbook's before close event Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim rng1 As Range Dim Rng2 As Range Set rng1 = Cells(1, 1) Set Rng2 = Cells(2, 1) If IsEmpty(rng1) Or IsEmpty(Rng2) Then MsgBox ("Required cells are empty") Cancel = True End If End Sub edit to fit your data Regards FSt1 "More Macro Help Needed" wrote: I am looking for a way to have a file run a macro when it is being closed (the user either hits the X or goes File Close). I want the macro to check certain cells and verify if there are values in them. If the cells are blank then I want an message box to come up saying that all cells are not filled in and the file remains open. Any help in this area is appreciated. Thanks Dan |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good stuff... I want to keep it in my posts so I will reply in addition to
the helpfull check. "FSt1" wrote: hi put this in the workbook's before close event Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim rng1 As Range Dim Rng2 As Range Set rng1 = Cells(1, 1) Set Rng2 = Cells(2, 1) If IsEmpty(rng1) Or IsEmpty(Rng2) Then MsgBox ("Required cells are empty") Cancel = True End If End Sub edit to fit your data Regards FSt1 "More Macro Help Needed" wrote: I am looking for a way to have a file run a macro when it is being closed (the user either hits the X or goes File Close). I want the macro to check certain cells and verify if there are values in them. If the cells are blank then I want an message box to come up saying that all cells are not filled in and the file remains open. Any help in this area is appreciated. Thanks Dan |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Run macro on exit | Excel Discussion (Misc queries) | |||
Exit via macro only? | Excel Discussion (Misc queries) | |||
Macro Exit or Link | Excel Programming | |||
on exit macro | Excel Discussion (Misc queries) | |||
Run Macro on cell exit | Excel Programming |