View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Efficient way to drtermine if a string contains digits?

On Thu, 30 Aug 2007 17:57:24 -0400, wrote:

What is the most efficient way to determine if any of the characters of a
string are digits?

One example would be a function that returns "TRUE" if one or more
characters of its single argument are digits and "FALSE" otherwise.

Thanks!!


Worksheet formula:

=NOT(ISNA(LOOKUP(9.9+307,--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},
A1&"0123456789")),ROW(INDIRECT("1:"&LEN(A1)))))))

VBA Function

=============================
Option Explicit
Function Num(str As String) As Boolean
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Pattern = "\d"
Num = re.test(str)
End Function
=========================
--ron