ISVALIDMOBILE
Intro

Checks if entered mobile number is structurally valid or not. Currently this validation is done for Indian mobile numbers as follows:

  • 10 digits
  • First digit should start with 7 / 8 / 9
  • Optional prefix of 0 or +91 or (+91)
Syntax
=ISVALIDMOBILE(mobile_number)
Input

mobile_number(String)
Cell Reference or Text containing mobile number

Output

(Boolean) Validation result as TRUE / FALSE

Code
Target Platform:

Function ISVALIDMOBILE(mobile_number As String) As Boolean
Dim expr As New RegExp
expr.Pattern = "^(\(\+91\)|\+91|0)?[7-9][0-9]{9}$"
ISVALIDMOBILE = expr.Test(mobile_number)
End Function
Download
Example

script library isvalidmobile example

Dependency (VBA)

This Excel VBA Macro uses Regular Expression feature, which is not available by default. So it has to be referenced in VBA Project using below steps

  1. In Excel press Alt + F11 which will open VBA Macro editor
  2. Go to Tools > References which will open VBA Project References dialog
  3. Locate & Tick Microsoft VBScript Regular Expression 5.5 as shown in below image
    script library regular expression dependency screenshot
  4. Click OK & close VBA Window
To write any comments or post queries, kindly sign-in to your Facebook & then refresh this page