Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to remove some special characters from string in Excel?

If there are some special characters such as %^&*() within the text strings, and now, you want to remove theses specific characters from the cell strings. To remove them one by one will be time-consuming, here, I will introduce some quick tricks for solving this task in Excel.

Remove some special characters from text string with User Defined Function

Remove some special characters from text string with Kutools for Excel


Remove numeric, alpha  or other special characters from text string:

Kutools for Excel's Remove Characters feature can help you to quickly remove all numeric, alpha, non-numeric, non-alpha, non-printing, other specific characters from text strings as you need. Click to Download and free trial Kutools for Excel Now!

doc remove special characters 7

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


arrow blue right bubble Remove some special characters from text string with User Defined Function


The following VBA code can help you to remove the specific characters you need, please do as follows:

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Remove some special characters from text string

Function RemoveSpecial(Str As String) As String
'updatebyExtendoffice 20160303
    Dim xChars As String
    Dim I As Long
    xChars = "#$%()^*&"
    For I = 1 To Len(xChars)
        Str = Replace$(Str, Mid$(xChars, I, 1), "")
    Next
    RemoveSpecial = Str
End Function

3. Then save and close this code, go back to the worksheet, and enter this formula: =removespecial(A2) into a blank cell where you want to put the result, see screenshot:

doc remove special characters 1

4. And then drag the fill handle down to the cells which you want to apply this formula, and all the special characters that you needn’t have been removed from the text string, see screenshot:

doc remove special characters 2

Note: In the above code, you can change the special characters #$%()^*& to any others that you want to remove.


If you are not skilled with the VBA code, Kutools for Excel’s Remove Characters utility can help you finish this task quickly and easily.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please so as follows:

1. Select the text strings that you want to remove some special characters.

2. Click Kutools > Text > Remove Characters, see screenshot:

doc remove special characters 3

3. In the Remove Characters dialog box, check Custom option under the Remove Characters section, and enter the special characters that you want to remove, see screenshot:

doc remove special characters 4

4. And then click Ok or Apply button, the characters you specified in the Custom textbox have been removed from the text strings at once, see screenshots:

doc remove special characters 5  2 doc remove special characters 6

Click to Download and free trial Kutools for Excel Now!


Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!



Recommended Productivity Tools

Office Tab

gold star1 Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.

Kutools for Excel

gold star1 Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!

gold star1 300 New Features for Excel, Make Excel Much Easy and Powerful:

  • Merge Cell/Rows/Columns without Losing Data.
  • Combine and Consolidate Multiple Sheets and Workbooks.
  • Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
  • Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
  • More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...

Screen shot of Kutools for Excel

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Kim · 1 months ago
    Hmm I wonder, does it only work in the worksheet you've originally pasted the code in?
    As for that one it only seems to work, not for any new workbook you open
    • To post as a guest, your comment is unpublished.
      skyyang · 1 months ago
      Hello, Kim,
      The VBA code can only applied in one workbook, if you want to apply it in a new workbook, you should copy and paste the code into your new workbook again.
      Thank you!
  • To post as a guest, your comment is unpublished.
    Kim · 1 months ago
    Hi guys,

    I've applied the =removespecial(A2) code and it works perfectly in one worksheet but then in the other it gives me an invalid #NAME? error.
    I checked the "format cells" and it's both on general and I've copied the same text + formula to both worksheets but it won't work.
    Any clue what this might cause this?

    Thanks and thank you so much for this code.
    Saves me hours and hours of work!

    Regards, Kim
  • To post as a guest, your comment is unpublished.
    Deepak · 9 months ago
    Function GetWordWOSpecChar(Rng As Range)
    'paste in VBA module, Use as a Formula
    'Created by Deepak Sharma
    Arr = Array("48", "49", "50", "51", "52", "53", "54", "55", _
    "56", "57", "65", "66", "67", "68", "69", "70", "71", "72", "73", "74", "75", _
    "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", _
    "89", "90", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106", _
    "107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", _
    "118", "119", "120", "121", "122")

    For i = 1 To Len(Rng.Value)
    txt = Mid(Rng.Value, i, 1)
    For g = 1 To UBound(Arr)
    If txt = Chr(Arr(g)) Then GetWord = Right(Rng.Value, Len(Rng.Value) - (i - 1)): Exit Function
    Next g
    Next i

    End Function