ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open & close event (https://www.excelbanter.com/excel-programming/383967-open-close-event.html)

Curt

open & close event
 
not having done this befor. use open event to start then in same workbook
code window can you put an close event sub. thinking that close will run on
all worksheets in workbook when closed? posed the question as am not good at
this. am expermitting only looking to find if I am going right way.
Thanks


NickHK

open & close event
 
Curt,
Is this what you mean ?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With WS
'do something
End With
Next

End Sub

NickHK

"Curt" wrote in message
...
not having done this befor. use open event to start then in same workbook
code window can you put an close event sub. thinking that close will run

on
all worksheets in workbook when closed? posed the question as am not good

at
this. am expermitting only looking to find if I am going right way.
Thanks




Curt

open & close event
 
Thank You

"NickHK" wrote:

Curt,
Is this what you mean ?

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets
With WS
'do something
End With
Next

End Sub

NickHK

"Curt" wrote in message
...
not having done this befor. use open event to start then in same workbook
code window can you put an close event sub. thinking that close will run

on
all worksheets in workbook when closed? posed the question as am not good

at
this. am expermitting only looking to find if I am going right way.
Thanks






All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com