View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Phil Hageman Phil Hageman is offline
external usenet poster
 
Posts: 80
Default Need final code tweak

Dave, thanks much for your reply. Not being a programmer,
I thought there might be a line of code that could simply
be added to what I have that would prevent the user from
leaving the worksheet. Is there? Could you help me with
it?
Thanks, Phil

-----Original Message-----
There's a worksheet_deactivate event that you could use.

And under the
ThisWorkbook module, you might want some code in the

workbook_beforeclose event,
too.



Phil Hageman wrote:

This worksheet code works okay - except that it allows

the
user to leave the worksheet without correcting the
improper cell data entries. They can click okay to the
message, and leave the worksheet. What additional code
could be added to make the user correct the data before
allowing them to leave the worksheet?

Private Sub Worksheet_Change(ByVal Target As Range)

If [M15] < [M16] Or [M47] < [M48] Or [M79] < [M80] Then
MsgBox "Target cannot be greater than Chart Max"
ElseIf [M16] < [M18] Or [M48] < [M50] Or [M80] < [M82]

Then
MsgBox "UCL cannot be greater than Target"
ElseIf [M18] < [M22] Or [M50] < [M54] Or [M82] < [M86]

Then
MsgBox "LCL cannot be greater than UCL"
End If
End Sub

Thanks, Phil


--

Dave Peterson

.