Problem with logical sentence

  • Thread starter Thread starter cecilia12345
  • Start date Start date
C

cecilia12345

i have this conditional sentence
If Cells(NumFilas, 2).Value <> "NAFF" Or Cells(NumFilas, 2).Value <
"NEQ" _
Or Cells(NumFilas, 2).Value <> "IBR" Then

.....

end if

however, the conditions are ignored when the program is running...
why
 
Cecilia,

I think you want ANDs instead of ORs. With ANDs, one of the <>
conditions will always be true, regardless of the value of
Cells(NumFilas,2).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Have you tried bracketing the equations? Might work..

eg.

If ((Cells(NumFilas, 2).Value <> "NAFF") Or (Cells(NumFilas, 2).Value <>
"NEQ") _
Or (Cells(NumFilas, 2).Value <> "IBR")) Then


John
 
I think you want ANDs instead of ORs. With ANDs, one of the <>

I meant With ANDs not ORs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


Chip Pearson said:
Cecilia,

I think you want ANDs instead of ORs. With ANDs, one of the <>
conditions will always be true, regardless of the value of
Cells(NumFilas,2).


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
-----Original Message-----
i have this conditional sentence
If Cells(NumFilas, 2).Value <> "NAFF" Or Cells(NumFilas,
2).Value said:
"NEQ" _
Or Cells(NumFilas, 2).Value <> "IBR" Then

.....

end if

however, the conditions are ignored when the program is running...
why?

Try sometihng like this



MyCheck = Cells(NumFilas, 2).Value <> "NAFF" Or Cells
(NumFilas, 2).Value <> "NEQ" _ Or Cells(NumFilas, 2).Value
<> "IBR"

If MyCheck = True then...
' ome
Else...
End If
 
Back
Top