Find and replace a character in a cell with another cell's content

  • Thread starter Thread starter JABAgdl
  • Start date Start date
J

JABAgdl

Hello, I have several strings of characters in column "A" and, a list of
special characters in column "B" and a list of replacement characters in
column "C". I would like to create a macro that copies B1 content, then look
for it in all column "A" cells and replace it with C1 content, then will copy
B2 content, look for it in column "A" and replace it with C2 content...and so
on until next cell in "B" column is blank. I tried an iterative function, but
it is not working as I expected. any and all help would be highly appreciated!
 
Try the below which will replace cell contents...referring to ColB/C..
Please note that the replacement is for entire cell contents and not
characters within the cell...

Sub FindandReplaceComplexMultiples()

Dim intTemp As Integer, arrFindReplace As Variant
arrFindReplace = ActiveSheet.Range("B1:C" & _
ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row)

For intTemp = 1 To UBound(arrFindReplace)
If Trim(arrFindReplace(intTemp, 1)) <> "" Then
Columns(1).Replace What:=arrFindReplace(intTemp, 1), _
Replacement:=arrFindReplace(intTemp, 2), _
LookAt:=xlWhole, SearchOrder:=xlByRows
End If
Next

End Sub

If this post helps click Yes
 
Back
Top