Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default 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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,393
Default 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!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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!


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
TO DELETE ONLY NUMERIC VALUES IN A CHARACTER AND NUMERIC CELL IN ramesh k. goyal - abohar[_2_] Excel Discussion (Misc queries) 1 October 28th 09 06:50 AM
How do I copy numeric section of cell from alpha-numeric cell ACCAguy Excel Worksheet Functions 8 September 8th 08 12:46 PM
Need to test for alphanumeric value and write numeric values to ce Pyramid 36 Excel Worksheet Functions 3 August 3rd 07 03:15 AM
Test IF Two Numeric Values Match (from two separate Dynamic Ranges) Sam via OfficeKB.com Excel Worksheet Functions 3 August 14th 05 12:20 AM
how can i test whether cell contains keyed constant or a formulae Ruthki Excel Worksheet Functions 6 June 22nd 05 12:44 PM


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

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

About Us

"It's about Microsoft Excel"