PDA

View Full Version : Solved: How to Detect Formula Is Present



Cyberdude
12-13-2005, 10:12 AM
I thought I had seen a function called ISFORMULA somewhere, but perhaps not. What's the best non-VBA way to detect if a cell contains a formula or not?

Zack Barresse
12-13-2005, 10:39 AM
You can't without VBA. A UDF would look like this ...


Option Explicit

Public Function IsFormula(celRef As Range) As Boolean
IsFormula = celRef.HasFormula
End Function

mdmackillop
12-13-2005, 10:53 AM
Hi Sid,
You could use Edit/GoTo/Special/Formula/OK and colour the selected cells for a quick visual check.
Regards
Malcolm

Cyberdude
12-13-2005, 11:16 AM
Thanx, guys. I was hoping that somewhere there was a function I could use in a formula. I suppose I could use Zack's contribution and put it in my Personal.xls for general reference. Thanx, Zack. :bow:

Zack Barresse
12-13-2005, 02:27 PM
And Sid, you did remember correctly ... http://www.vbaexpress.com/kb/getarticle.php?kb_id=324

Cyberdude
12-13-2005, 03:05 PM
Oops ... I KNEW I had seen it somewhere. :bug:

Emily
12-13-2005, 11:00 PM
I thought I had seen a function called ISFORMULA somewhere, but perhaps not. What's the best non-VBA way to detect if a cell contains a formula or not?

May be you are looking for Macro 4.0 GET.FORMULA

Suppose A1 = Sin(45)

Insert - Name - Define
Names in Workbooks: IsFormulaThere
Refer to: =GET.FORMULA(!$A$1)
C1= IsFormulaThere --> shows "= Sin(45)"

Bob Phillips
12-14-2005, 03:39 AM
May be you are looking for Macro 4.0 GET.FORMULA

Suppose A1 = Sin(45)


Insert - Name - Define
Names in Workbooks: IsFormulaThere
Refer to: =GET.FORMULA(!$A$1)
C1= IsFormulaThere --> shows "= Sin(45)"


Excel4 macros are notoriously unstable, copying and pasting the formula to another worksheet is know to cause Excel to crash. This is one situation where I would reverse my maxim of using Excel functioanlity where possible. the VBA solution is just so much safer.