ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   FORMULA VS VALUE (https://www.excelbanter.com/excel-worksheet-functions/212269-formula-vs-value.html)

Kathy Niebur

FORMULA VS VALUE
 
Is there a function in Excel or functions I could group together to determine
if the contents of a given cell are a formula vs. a value ? For example, I
would want to evaluate the contents of a cell displaying 3,450 to determine
if that was a number typed into the cell (a numeric value) vs the result of a
formula in the cell (=E5+E6) for example. I know how to manually display the
formulas in a worksheet. I want to write a formula to CHECK for the presence
or absence of a formula in a given cell. Being able to check for the EXACT
formula would be even better. For example, =IF(B3<"=E5+E6","NOT
CORRECT',"CORRECT")

Any help?

Gary''s Student

FORMULA VS VALUE
 
Try this tiny UDF:

Function isformula(r As Range) As Boolean
isformula = r.HasFormula
End Function

so that if A1 contains:
1
and A2 contains:
=1
then =isformula(A1) will return FALSE
and =isformula(A2) will return TRUE


UDFs are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the UDF will be saved with it.

To use the UDF from the normal Excel window, just enter it like a normal
Excel Function

To remove the UDF:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about UDFs, see:

http://www.cpearson.com/excel/Writin...ionsInVBA.aspx




--
Gary''s Student - gsnu200817


"Kathy Niebur" wrote:

Is there a function in Excel or functions I could group together to determine
if the contents of a given cell are a formula vs. a value ? For example, I
would want to evaluate the contents of a cell displaying 3,450 to determine
if that was a number typed into the cell (a numeric value) vs the result of a
formula in the cell (=E5+E6) for example. I know how to manually display the
formulas in a worksheet. I want to write a formula to CHECK for the presence
or absence of a formula in a given cell. Being able to check for the EXACT
formula would be even better. For example, =IF(B3<"=E5+E6","NOT
CORRECT',"CORRECT")

Any help?


Pete_UK

FORMULA VS VALUE
 
You could set up a simple user-defined function (UDF) like this:

Function IsFormula(mycell As Range) As Boolean
IsFormula = mycell.HasFormula
End Function

and then use it like this:

=IsFormula(A2)

to check if A2 contains a formula (returns TRUE or FALSE).

Hope this helps.

Pete

On Dec 2, 8:21*pm, Kathy Niebur <Kathy
wrote:
Is there a function in Excel or functions I could group together to determine
if the contents of a given cell are a formula vs. a value ? *For example, I
would want to evaluate the contents of a cell displaying 3,450 to determine
if that was a number typed into the cell (a numeric value) vs the result of a
formula in the cell (=E5+E6) for example. *I know how to manually display the
formulas in a worksheet. *I want to write a formula to CHECK for the presence
or absence of a formula in a given cell. *Being able to check for the EXACT
formula would be even better. *For example, =IF(B3<"=E5+E6","NOT
CORRECT',"CORRECT")

Any help?



Mike H

FORMULA VS VALUE
 
Hi,

the easiest is a UDF.

Alt +F11 to open VB editor, Right click 'This Workbook' and insert module
and paste the code below in

Function IsFormula(rng As Range) As String
If rng.HasFormula Then
IsFormula = "Correct"
Else
IsFormula = "Not Correct"
End If
End Function


Call with
=IsFormula(a1)

Mike

"Kathy Niebur" wrote:

Is there a function in Excel or functions I could group together to determine
if the contents of a given cell are a formula vs. a value ? For example, I
would want to evaluate the contents of a cell displaying 3,450 to determine
if that was a number typed into the cell (a numeric value) vs the result of a
formula in the cell (=E5+E6) for example. I know how to manually display the
formulas in a worksheet. I want to write a formula to CHECK for the presence
or absence of a formula in a given cell. Being able to check for the EXACT
formula would be even better. For example, =IF(B3<"=E5+E6","NOT
CORRECT',"CORRECT")

Any help?


Ashish Mathur[_2_]

FORMULA VS VALUE
 
Hi,

Though this does not get you exactly what you want, you can conditionally
format all the formula based cells. Please follow the undermentioned
procedu

1. Go to Insert Name (name the formula as €ścellhasformula€ť) and in the
€śRefers to€ť box, type the following formula = get.cell(48,indirect(€śrc€ť,false));
2. Now in the conditional formatting dialog box, type cellhasformula and use
the desired formatting.

Hope this helps.

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Kathy Niebur" <Kathy wrote in message
...
Is there a function in Excel or functions I could group together to
determine
if the contents of a given cell are a formula vs. a value ? For example,
I
would want to evaluate the contents of a cell displaying 3,450 to
determine
if that was a number typed into the cell (a numeric value) vs the result
of a
formula in the cell (=E5+E6) for example. I know how to manually display
the
formulas in a worksheet. I want to write a formula to CHECK for the
presence
or absence of a formula in a given cell. Being able to check for the
EXACT
formula would be even better. For example, =IF(B3<"=E5+E6","NOT
CORRECT',"CORRECT")

Any help?




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

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