I have looked all over but can´t find a command how I can replace a word between two special characters. I want to delete everything between the both brackets.
I only managed to delete one special character "(" but not the whole word between the brackets.
How should the result look like:
Example - Before: 26125 Oldenburg (Oldenburg), Alexandersfeld
Example - Afterwards: 26125 Oldenburg, Alexandersfeld
Option Explicit
Sub Bereinigen()
Dim Text As String
'Text = ActiveSheet.Cells(1, 1)
Text = "26125 Oldenburg (Oldenburg), Alexandersfeld"
If InStr(Text, "(") > 0 Then
Dim strSearchFor As String
Dim strReplaceWith As String
Dim strNewText As String
strSearchFor = "("
strReplaceWith = ""
strNewText = Replace(Text, strSearchFor, strReplaceWith)
Debug.Print strNewText
End If
End Sub
Aucun commentaire:
Enregistrer un commentaire