メインコンテンツへスキップ

Excelで文字列からいくつかの特殊文字を削除するにはどうすればよいですか?

次のような特殊文字がある場合 %^&*() テキスト文字列内で、ここで、これらの特定の文字をセル文字列から削除します。 それらをXNUMXつずつ削除するには時間がかかります。ここでは、Excelでこのタスクを解決するための簡単なトリックをいくつか紹介します。

ユーザー定義関数を使用して、テキスト文字列からいくつかの特殊文字を削除します

Kutools forExcelを使用してテキスト文字列からいくつかの特殊文字を削除します


矢印青い右バブル ユーザー定義関数を使用して、テキスト文字列からいくつかの特殊文字を削除します

次のVBAコードは、必要な特定の文字を削除するのに役立ちます。次のようにしてください。

1. 押したまま Alt + F11 キーを押して アプリケーション向け Microsoft Visual Basic 窓。

2に設定します。 OK をクリックします。 インセット > モジュール、次のコードをに貼り付けます モジュール 窓。

VBAコード:テキスト文字列からいくつかの特殊文字を削除します

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。 次に、このコードを保存して閉じ、ワークシートに戻って、次の数式を入力します。 = removespecial(A2) 結果を配置する空白のセルに、スクリーンショットを参照してください。

docは特殊文字を削除します1

4。 次に、この数式を適用するセルまで塗りつぶしハンドルをドラッグします。テキスト文字列から不要な特殊文字はすべて削除されています。スクリーンショットを参照してください。

docは特殊文字を削除します2

Note:上記のコードでは、特殊文字を変更できます #$%()^ *& 削除したい他の人に。


テキスト文字列から数字、英字、またはその他の特殊文字を削除する

Kutools for Excel's 文字を削除する 機能を使用すると、すべてをすばやく削除できます 数値の, アルファ, 非数値, 非アルファ, 非印刷, 他の特定の文字 必要に応じてテキスト文字列から。 クリックしてダウンロードし、Excel用の無料トライアルKutoolsを今すぐ!

docは特殊文字を削除します7

Kutools for Excel:300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます。 今すぐダウンロードして無料トライアル!


VBAコードに精通していない場合は、 Kutools for Excelさん 文字を削除する ユーティリティは、このタスクをすばやく簡単に完了するのに役立ちます。

インストールした後 Kutools for Excel、次のようにしてください。

1。 いくつかの特殊文字を削除するテキスト文字列を選択します。

2. クツール > テキスト > 文字を削除する、スクリーンショットを参照してください:

3。 の中に 文字を削除する ダイアログボックス、チェック カスタム オプションの下に 文字を削除する セクションをクリックし、削除する特殊文字を入力します。スクリーンショットを参照してください。

docは特殊文字を削除します4

4。 そして、 Ok or 申し込む ボタン、で指定した文字 カスタム テキストボックスはテキスト文字列から一度に削除されました。スクリーンショットを参照してください。

docは特殊文字を削除します5 2 docは特殊文字を削除します6

クリックしてダウンロードし、Excel用の無料トライアルKutoolsを今すぐ!


Kutools for Excel:300以上の便利なExcelアドインがあり、30日以内に制限なしで無料で試すことができます。 今すぐダウンロードして無料トライアル!

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Excelllent .. Five Stars.. thanks a lot
This comment was minimized by the moderator on the site
Thanks for this code
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

But it is possible that that can remove specific text? like "ab", "abc", "bc" and etc.
This comment was minimized by the moderator on the site
With Emoji need remove, how ?
This comment was minimized by the moderator on the site
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"
This comment was minimized by the moderator on the site
Hi, Nick,
Do you want to remove all ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 characters from the cells?
Looking forward to your reply, thank you!
This comment was minimized by the moderator on the site
No. I want to keep only "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations