ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Excel Ques? (https://www.excelbanter.com/excel-programming/366844-simple-excel-ques.html)

Mike

Simple Excel Ques?
 
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


Bob Phillips

Simple Excel Ques?
 
Add a UDF

Function IsFormula(rng as Range)
If rng.Coount = 1 Then
IsFormula = rng.HasFormula
End If
End SUb

and use like

=IF(Isformula(B2),....)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Mike" wrote in message
oups.com...
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




Jim Thomlinson

Simple Excel Ques?
 
Directly though Excel (not using VBA) I am affraid you can not do what you
are attempting. You can only read the return value of the function in the
cell, not the text of the function itself... Just wondering, how is it you
will not know what function that you have in the cell? maybe there is some
way to work around this...
--
HTH...

Jim Thomlinson


"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



Tom Ogilvy

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




All times are GMT +1. The time now is 10:56 PM.

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