View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default VB Code stops working

You have put it in Thisworkbook code module?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Michelle K" wrote in message
...
Here is the code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)


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

it's a simple code that just prevents the user from closing Excel without
answering the survey accordingly. It runs once and after that it doesn't
anymore.

"K Dales" wrote:

Can you post your code? Hard to know without seeing it.

"Michelle K" wrote:

I have a survey form where users can rate corporate performance. It

is made
up of radio buttons to rank efficiency. i designed it to prevent

closing and
printing if the answers are too skewed (we need 3 5's, 2 4'2 , etc)

It works
fine the first time you open the file. However, if you change your

answers
(say, rated it 4 and then want to change the rating to 3), the code

stops
working.

Why is this? How can I solve this issue?

Thanks so much,
Michelle K