View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Simple Excel Ques?

Unless you want to write a user defined function in VBA, you can't check the
formula of another cell using built in worksheet formulas.

Public Function checkformula(cell as Range)
set Target = Cell(1)
sForm = Target.Formula
if Left(sForm,3) = "=IF" then
checkformula = True
else
checkformula = false
end if
End Function

placed in a general module then in the worksheet

=Checkformula(B2)

alter the code to do exactly what you want.

--
Regards,
Tom Ogilvy


"Mike" wrote:

Hi everyone,

Say I have in cell B2 a function like this: "=If(c2=5,1,0)" OR this
"=1+34*x" and I want to check from cell F5 to see if what I have in B2
is like this:

if(or(b2 = "=If",b2="=1"),.....)

I don't want to put the whole function just the 1st part of it; if it
has "=If" or "=1"

How can I do so?

Thanks,
Mike