JaspeR_Etzi
New Member
- Joined
- Sep 19, 2018
- Messages
- 8
Hey you all,
I am pretty much a newbie to the whole Excel macro area and I tried my best to Google the answer for my problem but couldn't quite find a satisfying solution to it. So what I am trying to do is to censor all names from an Excel file by replacing the very next word of "herr", and "frau" (German for man and woman) to "*****". I have a working code that can replace certain words in an Excel spreadsheet but I am still trying to figure out how I can replace "the word next to the word" so to speak. Can anyone help me out with this?
Here is the code:
Sub FindandReplaceText()
'Update by Extendoffice 2018/5/24
Dim xFind As String
Dim xRep As String
Dim xRg As Range
On Error Resume Next
Set xRg =Cells
xFind = Application.InputBox("word to search:", "Kutools for Excel", , , , , 2)
xRep = Application.InputBox("word to replace:", "Kutools for Excel", , , , , 2)
If xFind = "False" Or xRep = "False" Then Exit Sub
xRg.Replace xFind, xRep, xlPart, xlByRows, False, False, False, False
End Sub
I am pretty much a newbie to the whole Excel macro area and I tried my best to Google the answer for my problem but couldn't quite find a satisfying solution to it. So what I am trying to do is to censor all names from an Excel file by replacing the very next word of "herr", and "frau" (German for man and woman) to "*****". I have a working code that can replace certain words in an Excel spreadsheet but I am still trying to figure out how I can replace "the word next to the word" so to speak. Can anyone help me out with this?
Here is the code:
Sub FindandReplaceText()
'Update by Extendoffice 2018/5/24
Dim xFind As String
Dim xRep As String
Dim xRg As Range
On Error Resume Next
Set xRg =Cells
xFind = Application.InputBox("word to search:", "Kutools for Excel", , , , , 2)
xRep = Application.InputBox("word to replace:", "Kutools for Excel", , , , , 2)
If xFind = "False" Or xRep = "False" Then Exit Sub
xRg.Replace xFind, xRep, xlPart, xlByRows, False, False, False, False
End Sub