Hello folks
Haven't been on here for a little while, hope everyone is well and someone might be able to help me?
I've written the following code to basically calculate if there are any blanks cells in a specific range and advise the user that they need to revisit these cells if they click to access any other sheet in the workbook:
Private Sub Worksheet_Deactivate()
Dim mval As Integer
Dim nval As Integer
mval = Application.WorksheetFunction.CountIf(Range("rngMain"), "Active
nval = Application.WorksheetFunction.CountIf(Range("rngDates"), ">0")
If mval - nval / 2 > 0 Then
MsgBox "Insert Warning Message Text here", vbCritical + vbOKOnly, "Insert Warning Message Title here"
End If
End Sub
This code works absolutely fine no problem.
The problem is that if the result of the calculation is greater than 0 the message box pops up AFTER the sheet has been deactivated and the user has successfully activated another sheet. What I want it to do is to calculate the formula and if the result is greater than 0 then it stops the deactivation of the worksheet, so that when the user reads the warning message and clicks the OK button they are still in the same sheet.
Is there a way of doing this at all?
Thanks everyone
Kenny
Bookmarks