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

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!
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top