View Single Post
  #4   Report Post  
Vacation's Over
 
Posts: n/a
Default Find and replace with a lookup

I get it now

YOu want to use worksheet functions Find and Substitute

Air code check syntax

dim myCellB as range
dim myCellA2 as range
dim myRangeB as range
Dim myRangeA2 as range

set myRangeB =' setittocolB
set myRangeA2 = 'setittorangeA2

for each myCellB in myRangeB
for each myCellA2 in myrangeA2
if iserror(worksheetfunction.Find(myCellB ,myCellA2) then
next myCellA2
Else:
worksheetfunction.substitute(myCellA2, myCellB, myCellB.offset(0,-1))
end If
next myCellA2
Next myCellB

set MyRangeB = nothing
set myRangeA2 = Nothing

"EMG03" wrote:

Column A2 is simply a separate column, unrelated to A and B. In other words,
in a separate worksheet.

"Vacation's Over" wrote:

please explain col A2

"EMG03" wrote:

I have two corresponding columns:

Column A
145431
145432
145433

Column B
DEFECT.1234
DEFECT.12351
DEFECT.1236

And another non-corresponding column that I want to modify with data from
Column A above:

Column A2
4645645DEFECT.1236131546
412312DEFECT.123487416
21168754DEFECT.1235155646

I want to search for a match between columns B and A2, and replace the
matching string within A2 with the corresponding value from A. Thanks in
advance.