ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Prevent deactivation of sheet (https://www.excelbanter.com/excel-programming/327493-prevent-deactivation-sheet.html)

Kobus

Prevent deactivation of sheet
 
Hi
In my workbook I have a number of sheets. Each sheet has certain cells that
must have specific values for my calculations on that sheet. I have a
procedure that checks whether everything is correct on a sheet. I want the
user to not be able to open the next sheet unless everything is correct on
the current sheet, but am struggling because there is not a
"BeforeDeactivate" or "BeforeActivate" procedure for the sheets. Can anyone
help?
Thanks

Widemonk

Prevent deactivation of sheet
 
Try this:-
Code:

Private Sub Worksheet_Deactivate()
If Range("a1") < True Then
Worksheets("sheet1").Select
MsgBox "You have not completed all the details.", vbCritical, "Incomplete
detail"
End If
End Sub

It wont stop users switching to another workbook, but if you wanted it to,
you could put a similar thing into the workbook module too.


All times are GMT +1. The time now is 10:25 PM.

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