Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 177
Default Is a cell a formula or value?

I'm stumped, I thought there used to be a =isformula to test whether a cell
is a formula or not.

How can I test for that to see if a formula got overwritten which I do want
it to do if a user chooses.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Is a cell a formula or value?

You can use a VBA UDF (user defined function):

Function IsFormula(cell_ref As Range)
IsFormula = cell_ref.HasFormula
End Function

Then you'd use it just like any other worksheet function:

=IsFormula(A1)

This will return either TRUE or FALSE.

You could also use this function to conditionally format the cells.

To use this:

Open the VBE editor: ALT F11
Open the Project Explorer: CTRL R
Locate your file name in the project explorer pane on the left.
Right click the file name
Select: InsertModule
Copy the code above and paste into the window on the right
Return back to Excel: ALT Q

Set the conditional formatting...
Select the cell(s) in question. Assume this is cell A1.
Goto FormatConditional Formatting
Formula Is: =IsFormula(A1)
Click the Format button
Select the desired style(s)
OK out


--
Biff
Microsoft Excel MVP


"todd" wrote in message
...
I'm stumped, I thought there used to be a =isformula to test whether a
cell
is a formula or not.

How can I test for that to see if a formula got overwritten which I do
want
it to do if a user chooses.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Is a cell a formula or value?

"T. Valko" wrote...
You can use a VBA UDF (user defined function):

Function IsFormula(cell_ref As Range)
* * IsFormula = cell_ref.HasFormula
End Function

....
This will return either TRUE or FALSE.

....

Actually it could also return #VALUE! if you try to pass it anything
that isn't a range reference. At the risk of slight overengineering,
you could use

Function isformula(c As Variant)
If Not TypeOf c Is Range Then
isformula = CVErr(xlErrRef)
Else
isformula = c.HasFormula
End If
End Function

which would return #REF! when the argument isn't a range reference. If
this udf would be used as just one term among many in longer formulas,
this could provide more meaningful diagnostics.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I make a blank cell in a formula cell with a range of cell Vi Excel Discussion (Misc queries) 5 June 21st 07 02:46 PM
adding a formula in a cell but when cell = 0 cell is blank Mike T Excel Worksheet Functions 5 May 31st 05 01:08 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 1 February 11th 05 06:36 AM
Cell Formula reference to cell Based On third Cell Content Gabriel Excel Discussion (Misc queries) 0 February 11th 05 05:35 AM
Cell doesn't show formula result - it shows formula (CTRL + ' doe. o0o0o0o Excel Worksheet Functions 6 November 19th 04 03:13 PM


All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"