ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find any number within string (https://www.excelbanter.com/excel-programming/340781-find-any-number-within-string.html)

R. Choate

Find any number within string
 
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.
--
RMC,CPA




[email protected]

Find any number within string
 

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
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------

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.



Norman Jones

Find any number within string
 
Hi R,

Try:

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


---
Regards,
Norman



"R. Choate" wrote in message
...
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.
--
RMC,CPA






R. Choate

Find any number within string
 
Thanks Norman ! I knew it was something like that but my memory just went blank.
--
RMC,CPA


"Norman Jones" wrote in message ...
Hi R,

Try:

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


---
Regards,
Norman



"R. Choate" wrote in message
...
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.
--
RMC,CPA








All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com