Find any number within string

  • Thread starter Thread starter R. Choate
  • Start date Start date
R

R. Choate

I need a line of code that will tell me if there is any numeric character within a string of text in a cell. The number could be
anywhere within the string, or there might not be any numbers in the string at all. I just need a true or false on this. Any
suggestions?

Thanks in advance.
 
Sub TestMe()
Dim bBo As Boolean

bBo = Alpha(Range("A1"))

End Sub

Function Alpha(rngR As Range) As Boolean
'' Does string contain numerics?

Dim intI As Integer

For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "*[0-9]*" Then _
Alpha = True: Exit Function
Next intI

End Function


HTH
Paul
 
Thanks Norman ! I knew it was something like that but my memory just went blank.
--
RMC,CPA


Hi R,

Try:

If ActiveCell.Value Like "*[0-9]*" Then 'contains a numeric character
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top