+ Reply to Thread
Results 1 to 6 of 6

Removing special characters

  1. #1
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    Removing special characters

    Hi All,

    I have 500K of fax number in excel. The fax number is mixed with special character, alphabets and numbers. Here I need to remove only the special characters and alpahabets from this column. Is there any vb code or a macro to do so. Please find the below example.

    example:

    Column A Need Like This

    +27(0)114831798 270114831798
    +27(0)11a5315080 270115315080
    +27(0)115606599 270115606599

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Removing special characters

    The below code allows you to display only the digits contained in a referenced dell:

    • ALT+F11...to open the VBA editor
    • Insert.Module

    In the new module:
    • Copy the below code and paste it into that module:

    Please Login or Register  to view this content.
    With
    A1: +27(0)114831798
    and
    B1: =PullDigits(A1)

    B1 returns: 270114831798

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Contributor
    Join Date
    07-17-2012
    Location
    bangalore
    MS-Off Ver
    Excel 2007
    Posts
    461

    Re: Removing special characters

    It is not working.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Removing special characters

    Try this array formula

    =NPV(-0.9,,IFERROR((MID(A1,256-COLUMN(A:IV),1)%),""))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    A
    B
    1
    +27(0)114831798
    270114831798
    2
    +27(0)11a5315080
    270115315080
    3
    +27(0)115606599
    270115606599
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Removing special characters

    "Not working" is a bit vague.
    Does it crash your computer? Return the wrong value? Doesn't compile?
    An example would be nice, too.

    I attached a file with a working example:
    sathishkm_demo.xlsm

    Note: Because the returned value is text, the function can accommodate a source value like this (Which has more than 15 significant digits):
    + 27(0)114831798 x3355

    For that value, the PullDigits function returns: 2701148317983355

    Does that help?
    Last edited by Ron Coderre; 08-22-2014 at 09:15 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Removing special characters

    Hi..

    Here's another possible way..

    Although it does use a loop.. the maximum number of loops is defined by how many values you want to check for).

    In this case.. I have added left and right brackets and the + symbol as well as a-z. Add more if you need.

    So.. although looping is to be avoided.. looping just 29 times to apply the Replace maybe not be that bad especially if you're doing 500K rows.

    Please Login or Register  to view this content.
    Edit: I just tested it on 200 000 rows.. it took about 15 seconds to complete.
    Attached Files Attached Files
    Last edited by apo; 08-23-2014 at 01:00 AM.

+ 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. [SOLVED] VBA removing special characters
    By vnzerem in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-21-2014, 11:55 AM
  2. [SOLVED] Formula for removing special characters.
    By alexgempesaw in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-15-2013, 01:31 AM
  3. Removing Duplicates and adding special characters
    By dawsonsoo in forum Excel General
    Replies: 7
    Last Post: 10-12-2011, 02:49 PM
  4. Consolidating VB code (Removing 29 different Special Characters)
    By adgjqetuo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2009, 07:25 AM
  5. Removing special characters in a text cell
    By Darrell in forum Excel General
    Replies: 0
    Last Post: 03-30-2005, 08:50 PM

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