+ Reply to Thread
Results 1 to 7 of 7

Need simple script to remove special characters in column A

  1. #1
    Registered User
    Join Date
    08-27-2013
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    10

    Need simple script to remove special characters in column A

    I am importing data and can't even begin to nail own all of the codes for the various characters. I want to keep a-z and 0-9 and "-" but, everything else must go.

    Also, this is for an excel macro.

    Thanks all.

  2. #2
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Need simple script to remove special characters in column A

    Easy enough but a little more detail is needed.
    1)Where is the data - need a range and explain if it's variable
    2) What about spaces? and A-Z

    Regards
    Tom

    If my answer resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post
    .

  3. #3
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Need simple script to remove special characters in column A

    Try this code to see if this works as per your requirement.
    Assuming your data is in col. A
    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Need simple script to remove special characters in column A

    try
    Please Login or Register  to view this content.
    If str Like "[A-Z,a-z,0-9,-]" Then
    You are including comma.

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Need simple script to remove special characters in column A

    Quote Originally Posted by jindon View Post

    You are including comma.
    Correct. Thanks for the correction.

  6. #6
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Need simple script to remove special characters in column A

    If there are multiple duplicate "bad" values then I think this algorithm will run a little faster as it replaces all the duplicate bad values at once?

    Please Login or Register  to view this content.
    Regards,

  7. #7
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Need simple script to remove special characters in column A

    jindon,

    That is some nice code, can you explain how the replace function does all the bad characters without looping? Obviously much faster than my solution.

    Thanks,

    Edit: Disregard, I did some web searching on VBScript RegExp Object and understand it now.
    Last edited by tom.hogan; 05-14-2014 at 05:15 PM.

+ 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] how remove all special characters except # , & - .
    By Latha Mani in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-13-2014, 07:14 AM
  2. How to remove special characters in a excel
    By Latha Mani in forum Excel General
    Replies: 6
    Last Post: 01-10-2014, 11:33 AM
  3. [SOLVED] Remove ALL Special Characters
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2013, 08:12 PM
  4. Remove special characters
    By humacdeep in forum Excel General
    Replies: 6
    Last Post: 01-14-2012, 03:36 PM
  5. Remove Special Characters
    By bkatzman in forum Excel General
    Replies: 10
    Last Post: 04-13-2010, 11:51 AM

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