How test if numeral is contained in a cell

xcellerator

New Member
Joined
Feb 22, 2017
Messages
23
Office Version
  1. 2019
Platform
  1. MacOS
A basic one...I am looking for a way to determine if a cell contains any numerals in the string (the cell is always a string of letters and/or numbers, not a function)
I realize I could do something like:
=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1))>0
But I was wondering if there is a function for this.
I don't think I could use ISTEXT(A1), nor ISNUMBER(A1)
Is there a function like containsnumeral(A1)?
So a cell with A2BCS or 2345 will return TRUE, for example.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi

You can write your own function
like
VBA Code:
 Function containsnumeral(r As Range) As Boolean
    With CreateObject("VBScript.RegExp")
        .Pattern = "\d"
            If .test(r) Then
                containsnumeral = True
           Else
                containsnumeral = False
            End If
      
    End With
End Function

use it :
=containsnumeral(A1)
 
Upvote 0
OOPs It is Mac OS
So just forget about my code
Sorry
 
Upvote 0
But Any way
Ver2 for other users if some body interested
VBA Code:
Function containsnumeral(r As Range) As Boolean
    With CreateObject("VBScript.RegExp")
        .Pattern = "\d"
        containsnumeral = IIf(.test(r), True, False)
    End With
End Function
 
Upvote 0
Mac doesn't support the dictionary object.

VBA Code:
Function ContainsNumeral2(aString As String) As Boolean
    ContainsNumeral2 = (aString Like "*#*")
End Function
 
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,831
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top