ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use of OR (https://www.excelbanter.com/excel-programming/303038-use.html)

No Name

Use of OR
 
Please tell me why this code does not work with the OR in
the code. If I delete the line Or Range("SupportUnrstrd")
(i).Offset(0, -21) < "550" it works. So I must be doing
something wrong with this OR. Please tell me. Thank you
for your help.



Dim i As Integer
For i = 1 To Range("SupportUnrstrd").Cells.Count
If Range("SupportUnrstrd")(i) < "" Then
If Range("SupportUnrstrd")(i).Offset(0,-
21) < "500" _
Or Range("SupportUnrstrd")(i).Offset
(0, -21) < "550" Then

Sheets("Admin Alloc").Range("A14").End
(xlDown).Offset(1, 0) = _
Range("SupportUnrstrd")(i).Offset(0, -
22)
End If
End If
Next i

Don Guillett[_4_]

Use of OR
 
Try using AND instead of OR

--
Don Guillett
SalesAid Software

wrote in message
...
Please tell me why this code does not work with the OR in
the code. If I delete the line Or Range("SupportUnrstrd")
(i).Offset(0, -21) < "550" it works. So I must be doing
something wrong with this OR. Please tell me. Thank you
for your help.



Dim i As Integer
For i = 1 To Range("SupportUnrstrd").Cells.Count
If Range("SupportUnrstrd")(i) < "" Then
If Range("SupportUnrstrd")(i).Offset(0,-
21) < "500" _
Or Range("SupportUnrstrd")(i).Offset
(0, -21) < "550" Then

Sheets("Admin Alloc").Range("A14").End
(xlDown).Offset(1, 0) = _
Range("SupportUnrstrd")(i).Offset(0, -
22)
End If
End If
Next i




No Name

Use of OR
 
Hi Don,

It seems that the use of AND tests for both conditions at
the same time and if both are not present then it is
included. However, the cell would contain one or the other
condition. So I am still trying to figure out what to do.
Thanks for your suggestion.

Regards

-----Original Message-----
Try using AND instead of OR

--
Don Guillett
SalesAid Software

wrote in message
...
Please tell me why this code does not work with the OR

in
the code. If I delete the line Or Range

("SupportUnrstrd")
(i).Offset(0, -21) < "550" it works. So I must be doing
something wrong with this OR. Please tell me. Thank you
for your help.



Dim i As Integer
For i = 1 To Range("SupportUnrstrd").Cells.Count
If Range("SupportUnrstrd")(i) < "" Then
If Range("SupportUnrstrd")(i).Offset(0,-
21) < "500" _
Or Range("SupportUnrstrd")(i).Offset
(0, -21) < "550" Then

Sheets("Admin Alloc").Range

("A14").End
(xlDown).Offset(1, 0) = _
Range("SupportUnrstrd")(i).Offset

(0, -
22)
End If
End If
Next i



.


Dick Kusleika[_3_]

Use of OR
 

If Range("SupportUnrstrd")(i).Offset(0,-
21) < "500" _
Or Range("SupportUnrstrd")(i).Offset
(0, -21) < "550" Then


this will always return True. If the cell does equal 500, then the second
part will be True and

True Or False = True

You'll never have a False Or False result, so every cell will be processed.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com




All times are GMT +1. The time now is 10:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com