View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default HOW-TO: Determine if a cell contains a number vs. formula vs. reference

ISREF doesn't behave as I expect it to. It returns TRUE when the cell contains
a literal number.

If what you want to know is whether the cell contains a formula, this VBA
function will do that:

Function CellHasFormula(aRange As Range) As Boolean
CellHasFormula = aRange.Cells(1).HasFormula
End Function


On Fri, 8 Oct 2004 18:08:37 -0700, List Lurker
wrote:

Hi All:

I'm trying to create a scoring sheet to analyze the type of data used in
another sheet.

E.g., if a cell is blank (i.e., no data entered), I want to give it "0",
if the cell contains an explicit number that was entered, I'll give it a
"1", and if there is a reference, presumably to some total on yet
another, supplemental sheet, the I'll give it a "2".

I've played around w/ the "IS" functions, but ISREF seems not to do what
I would expect ... i.e., if a cell has 123 in it, both ISNUMBER and
ISREF give me TRUE ....

Is there someway to distinguish, as per this last example, between an
explicit number a formula/reference (i.e., something starting with an
equal sign)?

Any help +/or ideas would be much obliged,

Out