View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default VBA referencing the result of a formula

VBA doesn't care whether a value is a constant or the result of a
formula:

If Range("B1").Value = "OK" Then
<whatever you're trying to do here
End If

However, a couple of ideas:

1) VBA comparisons are case sensitive. The above line will execute if
B1 = "OK", but not "Ok", "ok", "oK". You could try:

If LCase(Range("B1").Value) = "ok" Then

2) Your listed 'formula', if preceded by an "=" sign, is expecting
named values, Y and ok, rather than text literals (since they're not in
quotes). What are those values?



In article ,
Jock wrote:

If(A1=Y,ok,"")
Is it possible for code to reference column "B" (where this formula is) and
detect an 'ok' which has not been manually input?
The code I have works fine when 'ok' is entered but not when it is the
result of a formula.
Thanks