LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Find a value in a sheet and replace it with another value if it matches

I have a workbook with several sheets

DATA Errata and Errata 2

Data contains a large list of value but of interest is column D

I want to find if a partial value listed in Column D matches a value in
column A of errata then copy the value from Column C in Errata to column
D in data


EG

Data sheet column D contains the entry 123456ABC

Errata sheet column A row 3 contains 123456
Errata sheet column C row 3 contains XYZABC12

If the partial match is found I want the value in column D whatever row
it is in to now equal XYZABC12


So on a bigger scale

DATA_D ERRATA_A ERRATA_C
123abc 123 XYZ132
234abc 234a XZY495
678bde 132q PSU091
132qwe 678b ddeeff

Should have column D become
XYZ132
XZY495
ddeeff
PSU091

I've tried this but it doesn't work

Sub ReplaceMatches()

Dim shtOld As Worksheet, shtNew As Worksheet
Dim oldRow As Integer
Dim newRow As Integer
Dim i As Integer, id, f As Range



Set shtOld = ThisWorkbook.Sheets("Errata")
Set shtNew = ThisWorkbook.Sheets("Data")


For oldRow = 2 To 1711

id = shtOld.Cells(oldRow, 1)

Set f = shtNew.Range("D2:D1711").Find(id, , xlValues, xlPart)
If Not f Is Nothing Then
shtNew.activeCell.value = shtOld.Cells(oldRow, 3)


End If

Next oldRow

I know I'm not getting the right cell somewhere. Can someone help?


 
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 and Replace Sheet names FARAZ QURESHI Excel Discussion (Misc queries) 2 February 23rd 09 01:40 AM
Find 0s on Sheet and Replace with Formula SteveC Excel Programming 1 November 29th 07 08:59 PM
Find/Replace Event or Find/Replace for Protected Sheet ... Joe HM Excel Programming 2 October 27th 07 03:55 PM
Find Data from one sheet that matches Brian Shafer Excel Discussion (Misc queries) 1 October 19th 07 06:58 PM
trying to find #REF! in a formula to replace with a sheet name funkymonkUK[_212_] Excel Programming 5 June 28th 06 11:21 PM


All times are GMT +1. The time now is 05:03 PM.

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

About Us

"It's about Microsoft Excel"