Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
EMG03
 
Posts: n/a
Default Find and replace with a lookup

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.


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

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.


  #3   Report Post  
EMG03
 
Posts: n/a
Default Find and replace with a lookup

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.


  #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.


  #5   Report Post  
EMG03
 
Posts: n/a
Default Find and replace with a lookup

Thanks very much for the help. I added the real ranges and also created a
third range for my "column A" since that is what I want to replace the string
with. However I can't get the code to work. Error comes back on the NEXT
statement inside the IF statement (says "Next without For") and there is also
a problem with the substitute function. Error says "Expected: =" Any help
is appreciated. My code below:

Dim myCellA As Range
Dim myCellB As Range
Dim myCellA2 As Range
Dim myRangeA As Range
Dim myRangeB As Range
Dim myRangeA2 As Range

Set myRangeA = Worksheets("Updates Required").Range("E2:E1270")
Set myRangeB = Worksheets("Updates Required").Range("F2:F1270")
Set myRangeA2 = Worksheets("Updates Required").Range("C2:C1524")

For Each myCellA In myRangeA
For Each myCellB In myRangeB
For Each myCellA2 In myRangeA2
If IsError(WorksheetFunction.Find(myCellB, myCellA2)) Then
Next myCellA2
Else
worksheetfunction.substitute(myCellA2, myCellA, myCellA.offset(0,-1))
End If
Next myCellA
Next myCellB
Next myCellA2

Set myRangeA = Nothing
Set myRangeB = Nothing
Set myRangeA2 = Nothing

End Sub

"Vacation's Over" wrote:

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find nth occurrence and replace with ":" marlea Excel Worksheet Functions 4 October 5th 05 10:43 PM
find replace format neeraj Excel Discussion (Misc queries) 6 September 20th 05 05:50 PM
Find & Replace in VB macro JackC Excel Discussion (Misc queries) 1 August 24th 05 09:22 PM
Find and replace of word causes change of font formatting jwa90010 New Users to Excel 4 July 22nd 05 08:10 PM
VB Find and Replace Bony_Pony Excel Worksheet Functions 10 December 6th 04 05:45 PM


All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"