Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I have a simple code behind a spreadsheet that prevents it from closing
if some conditions are not satisfied. The code is: Private Sub Workbook_BeforeClose(Cancel As Boolean) 'MsgBox "Test if I am being evaluated" If (Range("C27") < 3 And Range("D27") < 2 And Range("E27") < 1 And Range("F27") < 2 And Range("G27") < 3 _ And Range("I27") < 3 And Range("J27") < 2 And Range("K27") < 1 And Range("L27") < 2 And Range("M27") < 3 _ And Range("C42") < 2 And Range("D42") < 2 And Range("E42") < 1 And Range("F42") < 2 And Range("G42") < 2 _ And Range("I42") < 2 And Range("J42") < 2 And Range("K42") < 1 And Range("L42") < 2 And Range("M42") < 2 _ And Range("C57") < 2 And Range("D57") < 2 And Range("E57") < 1 And Range("F57") < 2 And Range("G57") < 2 _ And Range("I57") < 2 And Range("J57") < 2 And Range("K57") < 1 And Range("L57") < 2 And Range("M57") < 2) Then MsgBox "You must complete the survey before closing." _ & " Please note the number of selections required per action.", vbExclamation, "CANNOT CLOSE" Cancel = True End If End Sub My issue is that it evaluates it a random number of times and then just stops evaluating it. It seems like it is getting disabled. However, I tried to add a msgbox at the top of the code just to see if it reads part of it and it does! Why is this happening? Help! Thanks, Michelle |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Subtotal has stopped working | Excel Worksheet Functions | |||
Drop-down boxes stopped working | Excel Discussion (Misc queries) | |||
Excel cell references to 2nd worksheet stopped working | Excel Worksheet Functions | |||
text to speech stopped working in excel | Excel Discussion (Misc queries) | |||
In-cell dropdown for validation stopped working | Excel Worksheet Functions |