Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It seems to be all right when I tested it. Are you sure that both values are
EXACTLY 0.44? Try manually entering BOTH values and test again. I suspect that one of them is not quite .44, perhaps due to a calculation or rounding? -- p45cal "anamarie30" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I test this code by enter manually the values and for that reason is EXACTLY
0.44 "p45cal" wrote: It seems to be all right when I tested it. Are you sure that both values are EXACTLY 0.44? Try manually entering BOTH values and test again. I suspect that one of them is not quite .44, perhaps due to a calculation or rounding? -- p45cal "anamarie30" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One way I got to getting the same message was if in the cell containing CDLL
was this: O.44 or o.44 as opposed to 0.44 Another stab in the dark: Check whether all the three cells are formatted in the same way. p45cal -- p45cal "anamarie30" wrote: I test this code by enter manually the values and for that reason is EXACTLY 0.44 "p45cal" wrote: It seems to be all right when I tested it. Are you sure that both values are EXACTLY 0.44? Try manually entering BOTH values and test again. I suspect that one of them is not quite .44, perhaps due to a calculation or rounding? -- p45cal "anamarie30" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
My 3rd Msgbox is popping up in wrong position | Excel Programming | |||
MsgBox To Read A Value of a cell | Excel Programming | |||
Msgbox saying "Unable to read file" | Excel Discussion (Misc queries) | |||
MsgBox execution sends program into design mode | Excel Programming | |||
Wrong text in msgbox | Excel Programming |