I have the following code:
Essentially this is an IF statement that I am trying to get to work but I am debugging to see where I am failing. What I want to work out is if all lines are TRUE except the last line why does the bottom statement come out as true? I would have expected a FALSE return if activecell.offset(0,5).value does not equal 999
Code:
Debug.Print InStr(1, ActiveCell.Offset(0, 14).Value, "1", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 14).Value, "2", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "3", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "4", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "5", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "6", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "7", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 2).Value, "8", vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 5).Value, 999, vbTextCompare) = 0
Debug.Print InStr(1, ActiveCell.Offset(0, 14).Value, "1", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 14).Value, "2", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "3", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "4", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "5", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "6", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "7", vbTextCompare) = 0 _
Or InStr(1, ActiveCell.Offset(0, 2).Value, "8", vbTextCompare) = 0 _
And InStr(1, ActiveCell.Offset(0, 5).Value, 999, vbTextCompare) = 0
Essentially this is an IF statement that I am trying to get to work but I am debugging to see where I am failing. What I want to work out is if all lines are TRUE except the last line why does the bottom statement come out as true? I would have expected a FALSE return if activecell.offset(0,5).value does not equal 999
Last edited: