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!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Nick DeCastro · 4 months ago
    Rather than searching for specific special characters, how about if you want to search for and replace ALL special characters. In other words, how would you write the search for NOT one of the following characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    • To post as a guest, your comment is unpublished.
      skyyang · 3 months ago
      Hi, Nick,
      Do you want to remove all ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 characters from the cells?
      Looking forward to your reply, thank you!
      • To post as a guest, your comment is unpublished.
        Nick DeCastro · 3 months ago
        No. I want to keep only "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
        • To post as a guest, your comment is unpublished.
          skyyang · 3 months ago
          Nick,
          Maybe the below VBA code can solve your problem, please try:

          Sub RemoveNotAlphasNotNum()
          Dim Rng As Range
          Dim WorkRng As Range
          On Error Resume Next
          xTitleId = "KutoolsforExcel"
          Set WorkRng = Application.Selection
          Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
          For Each Rng In WorkRng
          xOut = ""
          For i = 1 To Len(Rng.Value)
          xTemp = Mid(Rng.Value, i, 1)
          If xTemp Like "[a-z.]" Or xTemp Like "[A-Z.]" Or xTemp Like "[0-9.]" Then
          xStr = xTemp
          Else
          xStr = ""
          End If
          xOut = xOut & xStr
          Next i
          Rng.Value = xOut
          Next
          End Sub


          Hope it can help you!
  • To post as a guest, your comment is unpublished.
    Kim · 10 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 · 9 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 · 10 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 · 1 years 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