PDA

View Full Version : [SOLVED:] crieria item in list to replace in another column



Pamella
09-18-2019, 06:18 AM
1) List of items to search in column A
2) Range where list is. Contains text to replace


3) Code must loop Column A
4) Search Range("B:B")
5) Replace whatever search item from A is with the word "rate"


Sub Test()
Dim Sh As Worksheet

Set Sh = Sheets("Sheet1")
For Each Cel In Sh.Columns(1).SpecialCells(2)
With Sh.Cells
Set c = Sh.Columns(2).Find(Cel, lookat:=xlPart)


Do Until Cel Is Nothing
If Not Cel Is Nothing Then ' if found an item

Range("B:B").Replace What:=Cel, Replacement:="rate", lookat:=xlPart
End If
Cel = Cel.Offset(1, 0).Value
Loop

End With
Next
End Sub

SamT
09-18-2019, 05:23 PM
With Sh
For Each Cel In .Columns(1).SpecialCells(2)
Set c = .Columns(2).Find(Cel, lookat:=xlPart)
Do Until c Is Nothing
c.Replace What:=Cel, Replacement:="rate", lookat:=xlPart
Set c = .Findnext c
Loop
Next
End With

Pamella
09-19-2019, 02:49 AM
.

Pamella
09-19-2019, 02:52 AM
Thanks SamT,works a charm!