G
Guest
My code in the if case that state that "myCDR.Value = CDLL" do not give me
the msgbox carrectly. When I run my code and myCDR.Value = 0.44=CDLL the
msgbox box that gave me is that is state that "myCDR.Value < CDLL" and I do
not know why this occur. Suggestions will be appreciated. My code is:
------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CDR As Range
Dim myCDR As Range
Dim CDLL As Variant
Dim CDUL As Variant
Set CDR = ThisWorkbook.Sheets("PERIOD 1").Range("E66")
Set CDLL = ThisWorkbook.Sheets("LIMITS").Range("A3")
Set CDUL = ThisWorkbook.Sheets("LIMITS").Range("B3")
For Each myCDR In CDR
If IsEmpty(myCDR.Value) Or Trim(myCDR.Value) = "" Then
myCDR.Interior.ColorIndex = 15
Else
If myCDR.Value > CDLL And myCDR.Value < CDUL Then
myCDR.Interior.ColorIndex = 15
Else
If myCDR.Value < CDLL Then
MsgBox "LOT EXCEED THE COSMETIC DEFECT LOWER LIMIT (" &
CDLL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value > CDUL Then
MsgBox "LOT EXCEED THE COSMETIC DEFECT UPPER LIMIT ("
& CDUL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value = CDLL Then
MsgBox "LOT REACH THE COSMETIC DEFECT LOWER LIMIT
(" & CDLL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value = CDUL Then
MsgBox "LOT REACH THE COSMETIC DEFECT UPPER
LIMIT (" & CDUL & ")!"
myCDR.Interior.ColorIndex = 3
End If
End If
End If
End If
End If
End If
Next
End Sub
the msgbox carrectly. When I run my code and myCDR.Value = 0.44=CDLL the
msgbox box that gave me is that is state that "myCDR.Value < CDLL" and I do
not know why this occur. Suggestions will be appreciated. My code is:
------------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CDR As Range
Dim myCDR As Range
Dim CDLL As Variant
Dim CDUL As Variant
Set CDR = ThisWorkbook.Sheets("PERIOD 1").Range("E66")
Set CDLL = ThisWorkbook.Sheets("LIMITS").Range("A3")
Set CDUL = ThisWorkbook.Sheets("LIMITS").Range("B3")
For Each myCDR In CDR
If IsEmpty(myCDR.Value) Or Trim(myCDR.Value) = "" Then
myCDR.Interior.ColorIndex = 15
Else
If myCDR.Value > CDLL And myCDR.Value < CDUL Then
myCDR.Interior.ColorIndex = 15
Else
If myCDR.Value < CDLL Then
MsgBox "LOT EXCEED THE COSMETIC DEFECT LOWER LIMIT (" &
CDLL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value > CDUL Then
MsgBox "LOT EXCEED THE COSMETIC DEFECT UPPER LIMIT ("
& CDUL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value = CDLL Then
MsgBox "LOT REACH THE COSMETIC DEFECT LOWER LIMIT
(" & CDLL & ")!"
myCDR.Interior.ColorIndex = 3
Else
If myCDR.Value = CDUL Then
MsgBox "LOT REACH THE COSMETIC DEFECT UPPER
LIMIT (" & CDUL & ")!"
myCDR.Interior.ColorIndex = 3
End If
End If
End If
End If
End If
End If
Next
End Sub