Results 1 to 6 of 6

Thread: Remove Special Characters From Text Or Remove Numbers From Text

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    @snb and ExcelFox...

    And I couldn't help developting a non-RegExp function...
    Code:
    Enum WhatToRemove
      Text = 0
      numeric = 1
      SpecialCharacters = 2
    End Enum
    
    Function RemoveCharacters(ByVal StringToReplace As String, WhatRemove As WhatToRemove) As String
      Dim X As Long, Pattern() As String
      Pattern = Split("[A-Za-z] # [#~!@$%^&*()'={}[:""+;<>?,./\-]")
      If WhatRemove = SpecialCharacters Then StringToReplace = Replace(StringToReplace, "]", "")
      For X = 1 To Len(StringToReplace)
        If Mid(StringToReplace, X, 1) Like Pattern(WhatRemove) Then Mid(StringToReplace, X, 1) = Chr(1)
      Next
      RemoveCharacters = Replace(StringToReplace, Chr(1), "")
    End Function
    Note: I used snb's special characters list as it seemed more complete to me, although I also chose to remove the backslash character as well (you both allowed it to remain when special characters were to be removed).
    Last edited by Rick Rothstein; 05-31-2013 at 02:19 PM.

Similar Threads

  1. Extract Certain Characters From A Text String
    By bobkap in forum Excel Help
    Replies: 5
    Last Post: 05-24-2013, 06:25 AM
  2. Replies: 10
    Last Post: 12-10-2012, 11:28 PM
  3. Remove Numerics From Text
    By VIMAL CHALISSERY in forum Excel Help
    Replies: 2
    Last Post: 04-12-2012, 08:43 PM
  4. Remove Special Characters :
    By Rajan_Verma in forum Rajan Verma's Corner
    Replies: 3
    Last Post: 03-06-2012, 09:41 PM
  5. Remove Zero / Zeroes From Alphanumeric Text
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 04-04-2011, 01:16 AM

Posting Permissions

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