This is similar to this thread.
The difference is I am trying to use Evaluate IF(OR this time instead of Evaluate IF(AND.
Also In the previous thread mentioned, all the values were erased, this time all values are set to the 'true' value.
Is there a trick to get this to work also?
Single cell formula that works:
=IF(OR(A1="Good",B1="Good"),"OK",A1)
Code I am trying to use:
Anyone know the 'trick' to get this to with for 'OR' instead of 'AND'?
The solution provided by @StephenCrump in the previously mentioned thread was:
The difference is I am trying to use Evaluate IF(OR this time instead of Evaluate IF(AND.
Also In the previous thread mentioned, all the values were erased, this time all values are set to the 'true' value.
Is there a trick to get this to work also?
Single cell formula that works:
=IF(OR(A1="Good",B1="Good"),"OK",A1)
Book3 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Definitely | Good | |||
2 | Good | Good | |||
3 | Maybe | Bad | |||
4 | Maybe | Good | |||
5 | Maybe | Bad | |||
6 | Definitely | Good | |||
7 | Definitely | BAD | |||
8 | Maybe | BAD | |||
9 | Definitely | Good | |||
10 | Definitely | Good | |||
11 | |||||
Sheet1 |
Code I am trying to use:
VBA Code:
Sub TestEvaluateIF_OR_V1()
'
' Check values in A1:B10
'
With Range("A1:A10")
.Value = Evaluate("=IF(OR(" & .Address & "=""Good""," & .Offset(, 1).Address & _
"=""Good""),""OK""," & .Address & ")") ' If cell in Column A range = 'Good' OR cell
' ' in Column B range = 'Good' then change
' ' Column A cell to 'OK' Else leave the value as is
End With
End Sub
Anyone know the 'trick' to get this to with for 'OR' instead of 'AND'?
The solution provided by @StephenCrump in the previously mentioned thread was:
VBA Code:
Sub TestEvaluateIF_AND()
'
' Check values in A1:B10 AND needs to be replaced with '*' ;)
'
With Range("A1:A10")
.Value = Evaluate("IF((" & .Address & "= ""Definitely"")*(" & _
.Offset(, 1).Address & "= ""Good""), ""OK""," & .Address & ")") ' If cell in Column A range = 'Definitely' AND cell
' ' in Column B range = 'Good' then change
' ' Column A cell to 'OK' Else leave the value as is
End With
End Sub