• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Want to remove Special Charaters From Address List

Ajayjati25

New Member
Dear Sir

I have address list of about 10k Dealers which contains various special Charactors Like !@#-&*-;,./ Now i want to remove this special Charactors from address list. Please help me out on this problem.
 
Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column <> 2 Then Exit Sub
    Application.EnableEvents = False
    Target.Value = ValidFilename(Target.Value)
    Application.EnableEvents = True
End Sub
Function ValidFilename(p_file As String) As String
    Dim nChars As String
    Dim i As Integer
    nChars = "<>|\/|*?:{}"
    ValidFilename = p_file
    For i = 1 To Len(nChars)
      ValidFilename = Replace(ValidFilename, Mid(nChars, i, 1), "", 1, -1, vbBinaryCompare)
    Next i
End Function
In this line of code, add the characters you want to remove
Code:
 nChars = "<>|\/|*?:{}"
Code goes in the sheet you want to change.
 
Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column <> 2 Then Exit Sub
    Application.EnableEvents = False
    Target.Value = ValidFilename(Target.Value)
    Application.EnableEvents = True
End Sub
Function ValidFilename(p_file As String) As String
    Dim nChars As String
    Dim i As Integer
    nChars = "<>|\/|*?:{}"
    ValidFilename = p_file
    For i = 1 To Len(nChars)
      ValidFilename = Replace(ValidFilename, Mid(nChars, i, 1), "", 1, -1, vbBinaryCompare)
    Next i
End Function
In this line of code, add the characters you want to remove
Code:
 nChars = "<>|\/|*?:{}"
Code goes in the sheet you want to change.




Sir

Where should i use this code.
as in my excel file address is in 2nd column. Please find attached herewith sample of my excel data files. File name is also changing as per geneations of files. So please help
 

Attachments

Back
Top