I have this code, it just takes 3 words from user, looks for words in b,c and d and changes value to XXXXXXXXXXXXX.
The problem is that I get
unable to get findnext property of range class
I need this code to do multiple searches with different words and replace values without closing/resetting excel.
And if it is possible, when it does not fiind value in b, should go and execute the next piece of code.
The code looks for words in paragraphs.
Could someone please point me in the right direction?
Private Sub CommandButton1_Click()
Dim x As String
Dim y As String
Dim z As String
x = InputBox("enter word")
y = InputBox("enter word")
z = InputBox("enter word")
With Worksheets(1).Range("b2:b1000")
Set b = Cells.Find(x)
If Not b Is Nothing Then
firstAddress = b.Address
Do
b.Value = "XXXXXXXXXXXXX"
Set b = .FindNext(b)
Loop While Not b Is Nothing
End If
End With
With Worksheets(1).Range("c2:c1000")
Set c = Cells.Find(y)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = "XXXXXXXXXXXXX"
Set c = .FindNext(c)
Loop While Not c Is Nothing
End If
End With
With Worksheets(1).Range("d2:d1000")
Set d = Cells.Find(z)
If Not d Is Nothing Then
firstAddress = d.Address
Do
d.Value = "XXXXXXXXXXXXX"
Set d = .FindNext(d)
Loop While Not d Is Nothing
End If
End With
End Sub