![]() |
Test for numeric constant in a cell
Using Win XP with Office 2007;
I would like to test the contents of a cell to determine if it contains a numeric constant (i.e. a number, but not a date, or formula). For example, you would use IsDate to test for a date; is there an equivalent for a numeric constant? 1) Could an example function be posted that returns true if the current cell contains a numeric constant? Also, is there a type for a formula? 2) If so, could an example function be posted that returns true if the current cell contains a formula? 3) A formula that evaluates to a number? Thanks in advance! |
Test for numeric constant in a cell
Function Ntest(mycell)
If IsDate(mycell.Value) Then Ntest = False ElseIf mycell.HasFormula Then Ntest = False Else Ntest = WorksheetFunction.IsNumber(mycell.Value) End If End Function Note that a value such as 12 typed into a cell formatted as text will return FALSE with this UDF best wishes -- Bernard V Liengme Microsoft Excel MVP http://people.stfx.ca/bliengme remove caps from email "XP" wrote in message ... Using Win XP with Office 2007; I would like to test the contents of a cell to determine if it contains a numeric constant (i.e. a number, but not a date, or formula). For example, you would use IsDate to test for a date; is there an equivalent for a numeric constant? 1) Could an example function be posted that returns true if the current cell contains a numeric constant? Also, is there a type for a formula? 2) If so, could an example function be posted that returns true if the current cell contains a formula? 3) A formula that evaluates to a number? Thanks in advance! |
Test for numeric constant in a cell
This might work...
Function IsNumConst(Cell As Range) As Boolean With Cell IsNumConst = (CStr(.Value) = CStr(.Formula)) And IsNumeric(.Value2) End With End Function -- Rick (MVP - Excel) "XP" wrote in message ... Using Win XP with Office 2007; I would like to test the contents of a cell to determine if it contains a numeric constant (i.e. a number, but not a date, or formula). For example, you would use IsDate to test for a date; is there an equivalent for a numeric constant? 1) Could an example function be posted that returns true if the current cell contains a numeric constant? Also, is there a type for a formula? 2) If so, could an example function be posted that returns true if the current cell contains a formula? 3) A formula that evaluates to a number? Thanks in advance! |
All times are GMT +1. The time now is 10:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com