Need final code tweak
Hi Tom. This is the required order of things:
Cell Name
M15 Chart Max
M16 Target (Other cell names in the IF
M18 UCL ElseIf lines are repeats of the
M22 LCL same situation in other locations
M26 Op Zero in the same worksheet.)
M29 Chart Min
Values must descend from M15 to M29. These values are
flowing into a matrix that creates a combination chart.
I'm trying to enforce this with the users. Since I have
40 cases of this workbook, I would like to place the code
in the workbook module for ease of implementation and
maintenance.
Any advice?
Thanks, Phil
-----Original Message-----
If i read the logic of your code/messages correctly
you check if [M15] is less than [M16]; if it is you say
Target cannot be
greater than Chart max, so [M16] must be the target and
[M15] must be the
chart max
you then check if [M16] is less than [M18]; if it is you
say UCL cannot be
greater than Chart Max, so [M16] must be the chart max
and [M18] must be the
UCL
you then check if [M18] is less than [M22]; if it is you
say LCL cannot be
greater than UCL, so [M22] must be LCL and [M18] must be
the UCL
[M15] - chart max
[M16] - both target and chart max
[M18] - UCL
[M22] - LCL
Maybe I am misinterpreting, but perhaps you need to take
another look.
--
Regards,
Tom Ogilvy
Phil Hageman wrote in message
...
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
.
|