ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to detect if a cell is formula (https://www.excelbanter.com/excel-programming/299906-re-how-detect-if-cell-formula.html)

Soo Cheon Jheong

How to detect if a cell is formula
 
Hi

If a cell A1 contains the formula (for example, =SUM(K2:K1000) ),
Select a cell B1, from the formula menu, choose [Define Name].

In the Name box, type a name HASFORMULA and In the Refers To box,
type a formula =EVALUATE(GET.CELL(48,!A1)), and choose
the [Add] button and then [Close] button.

In a cell B1, enter the formula:

=HASFORMULA

--
Regards,

Soo Cheon Jheong
Seoul, Korea
http://excel.hompy.com
_ _
^вп^
--



Bob Phillips[_7_]

How to detect if a cell is formula
 
Better to create a UDF than rely on EVALUATE, as there is a serious problem
with EVALUATE.

The UDF would look like

Function HASFORMULA(rng As Range)
If rng.Count = 1 Then
HASFORMULA = rng.HASFORMULA
Else
HASFORMULA = CVErr(xlErrRef)
End If
End Function


--
HTH

-------

Bob Phillips
"Soo Cheon Jheong" wrote in message
...
Hi

If a cell A1 contains the formula (for example, =SUM(K2:K1000) ),
Select a cell B1, from the formula menu, choose [Define Name].

In the Name box, type a name HASFORMULA and In the Refers To box,
type a formula =EVALUATE(GET.CELL(48,!A1)), and choose
the [Add] button and then [Close] button.

In a cell B1, enter the formula:

=HASFORMULA

--
Regards,

Soo Cheon Jheong
Seoul, Korea
http://excel.hompy.com
_ _
^вп^
--






All times are GMT +1. The time now is 03:03 AM.

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