+ Reply to Thread
Results 1 to 7 of 7

Phone Number Validation -> REGEXMATCH for digits?

  1. #1
    Registered User
    Join Date
    11-01-2017
    Location
    Tel Aviv
    MS-Off Ver
    2016
    Posts
    3

    Phone Number Validation -> REGEXMATCH for digits?

    Hi,
    I'm looking to make an excel formula based on the following logic. Preferably not scripting etc. I am trying to validate numbers for a phone dialer.


    In column (a) I have phone numbers (no special characters)
    in column (b) I have the correct country code for that number's country

    IF (a) starts with 0, drop the 0. Lets call that (a-0)
    IF (a-0) starts with (b), print (a-0)
    ELSE print (b)&(a-0)
    Attached Files Attached Files
    Last edited by MagellanCapital; 07-06-2021 at 10:04 AM. Reason: adding sample workbook

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel (Windows 11 64-bit)
    Posts
    62,010

    Re: Phone Number Validation -> REGEXMATCH for digits?

    Welcome to the forum.

    10 is NOT an Excel version - please update your forum profile.

    Please provide a sample workbook - instructions in the yellow banner at the top.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" to anyone who has offered you help in your thread. You can reward them by clicking on * Add Reputation below theur user name on the left, if you wish.


    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.

  3. #3
    Registered User
    Join Date
    11-01-2017
    Location
    Tel Aviv
    MS-Off Ver
    2016
    Posts
    3

    Re: Phone Number Validation -> REGEXMATCH for digits?

    thanks updated

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel (Windows 11 64-bit)
    Posts
    62,010

    Re: Phone Number Validation -> REGEXMATCH for digits?

    Maybe this:

    =B2&IF(LEFT(A2,1)="0",RIGHT(A2,LEN(A2)-1),IF(VALUE(LEFT(A2,LEN(B2)))=B2,RIGHT(A2,LEN(A2)-LEN(B2)),A2))

    You may need to change commas to semi-colons for your locale.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    Waterlooville,England
    MS-Off Ver
    Office 2010
    Posts
    23,257

    Re: Phone Number Validation -> REGEXMATCH for digits?

    Try

    =IF(LEFT(A2,1)<>"0",IF(LEFT(A2,LEN(B2))=B2,A2,B2&A2),B2&MID(A2,2,LEN(A2)-1))

  6. #6
    Registered User
    Join Date
    11-01-2017
    Location
    Tel Aviv
    MS-Off Ver
    2016
    Posts
    3

    Re: Phone Number Validation -> REGEXMATCH for digits?

    Quote Originally Posted by AliGW View Post
    Maybe this:

    =B2&IF(LEFT(A2,1)="0",RIGHT(A2,LEN(A2)-1),IF(VALUE(LEFT(A2,LEN(B2)))=B2,RIGHT(A2,LEN(A2)-LEN(B2)),A2))

    You may need to change commas to semi-colons for your locale.
    You are my hero! Thank you very much!!

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel (Windows 11 64-bit)
    Posts
    62,010

    Re: Phone Number Validation -> REGEXMATCH for digits?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. AutoFilter phone number column while keeping phone number formatting
    By Daneyuleb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2021, 12:49 AM
  2. [SOLVED] Phone number format - reference post (Formatting Textbox to type phone numbers only)
    By eddyrcabrera79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-01-2015, 05:35 PM
  3. phone number extraction - 11 digits
    By whitlander in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2014, 10:24 AM
  4. [SOLVED] Data Validation: Phone Number
    By PolarX in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-29-2013, 12:49 PM
  5. Is it possible to make Excel dial a phone number from my smart phone?
    By D_Step in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-19-2013, 06:11 PM
  6. Replies: 5
    Last Post: 08-02-2011, 03:08 AM
  7. [SOLVED] validation for phone number
    By Candice in forum Excel General
    Replies: 3
    Last Post: 04-28-2006, 03:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1