+ Reply to Thread
Results 1 to 3 of 3

Remove symbols from String

  1. #1
    Registered User
    Join Date
    07-18-2011
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Remove symbols from String

    Does anyone know a VBA code to remove symbols from strings? I'm importing a file that comprises of Alphabets and Numeric characters but sometimes has all different types of symbols in random places. For example, it might be TES1244##56@@ but all I want is TES124456. The problem is the symbols appear in random locations so I thought about editing this code below but the problem is it removes only numeric numbers which I want to keep. Is there a way the I can make the for loop loop from 1 to 256, convert index i to an ascii character, then use Application.Substitude(TMP,(ascii index i),"")? Thanks

    ----------------------------------------------------------
    Please Login or Register  to view this content.
    -----------------------------------------------------------
    Last edited by pike; 12-15-2011 at 03:38 AM. Reason: add code tags for newbie

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Remove symbols from String

    You can try with this code:
    PHP Code: 
    Function RemoveSymbol(str As String) As String
    With CreateObject
    ("VBScript.RegExp")
        .Global = 
    True
        
    .Pattern "[^0-9A-z]"
        
    RemoveSymbol = .Replace(str"")
    End With
    End 
    Function 
    My English is very bad. I'm sorry if you feel uncomfortable.

  3. #3
    Registered User
    Join Date
    07-18-2011
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Remove symbols from String

    You're english is great so far. Cảm ơn rất nhiều it's a big help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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