Trying to get Evaluate(IF(AND to work.
Code that works:
Code that erases all values from Column A:
Before I smash this computer, Please let me know what I am messing up.
Code that works:
VBA Code:
Sub TestEvaluateIF()
'
' Check values in A1:A10
'
With Range(Cells(1, 1), Cells(10, 1))
.Value = Evaluate("IF(" & .Address & "= ""Good"", ""OK""," & .Address & ")") ' If cell in Column A range = 'Good' then change Column A
' ' cell to 'OK' Else leave the value as is
End With
End Sub
Code that erases all values from Column A:
VBA Code:
Sub TestEvaluateIF_And()
'
' Check values in A1:B10 via offset ... This erases all values from Column A for some reason?
'
With Range(Cells(1, 1), Cells(10, 1))
.Value = Evaluate("IF(AND(" & .Address & "= ""Definitely"", " & _
.Offset(, 1).Address & "= ""Good""), ""OK""," & .Address & ")") ' If cell in Column A range = 'Definitely' & cell
' ' in Column B range = 'Good' then change
' ' Column A cell to 'OK' Else leave the value as is
End With
End Sub
Book1 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Definitely | Good | |||
2 | Definitely | 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 |
Before I smash this computer, Please let me know what I am messing up.