View Single Post
  #2   Report Post  
Don Guillett
 
Posts: n/a
Default

I tried testing and didn't have a problem. But maybe you should group
if range("c27,g27,i27")<3
and perhaps you really want OR instead of AND???

--
Don Guillett
SalesAid Software

wrote in message
ups.com...
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