Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying use VBA to:
locate the value that is in Sheet"a" column b, row 2 in Sheet"b" then replace value in Sheet"b", column J with value from Sheet"a" column K increment to Sheet"a" column b, row 3 Find matching value in Sheet"b" replace value in Sheet"b", column J with value from Sheet"a" column K Thanks in advance, -- JohnM |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi John
Try the below and feedback Sub FindandReplace() Dim ws1 As Worksheet, ws2 As Worksheet Dim lngRow As Long Set ws1 = Worksheets("a") Set ws2 = Worksheets("b") For lngRow = 2 To ws1.Cells(Rows.Count, "B").End(xlUp).Row If Trim(ws1.Range("b" & lngRow)) < "" And _ Trim(ws1.Range("k" & lngRow)) < "" Then _ ws2.Columns("J:J").Replace What:=ws1.Range("B" & lngRow), _ Replacement:=ws1.Range("k" & lngRow), LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False Next End Sub If this post helps click Yes --------------- Jacob Skaria "JohnM" wrote: I am trying use VBA to: locate the value that is in Sheet"a" column b, row 2 in Sheet"b" then replace value in Sheet"b", column J with value from Sheet"a" column K increment to Sheet"a" column b, row 3 Find matching value in Sheet"b" replace value in Sheet"b", column J with value from Sheet"a" column K Thanks in advance, -- JohnM |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Jacob, this worked great! It was soooooo much simpler than what I was
trying to do in my script. -- JohnM "Jacob Skaria" wrote: Hi John Try the below and feedback Sub FindandReplace() Dim ws1 As Worksheet, ws2 As Worksheet Dim lngRow As Long Set ws1 = Worksheets("a") Set ws2 = Worksheets("b") For lngRow = 2 To ws1.Cells(Rows.Count, "B").End(xlUp).Row If Trim(ws1.Range("b" & lngRow)) < "" And _ Trim(ws1.Range("k" & lngRow)) < "" Then _ ws2.Columns("J:J").Replace What:=ws1.Range("B" & lngRow), _ Replacement:=ws1.Range("k" & lngRow), LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False Next End Sub If this post helps click Yes --------------- Jacob Skaria "JohnM" wrote: I am trying use VBA to: locate the value that is in Sheet"a" column b, row 2 in Sheet"b" then replace value in Sheet"b", column J with value from Sheet"a" column K increment to Sheet"a" column b, row 3 Find matching value in Sheet"b" replace value in Sheet"b", column J with value from Sheet"a" column K Thanks in advance, -- JohnM |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great..
If this post helps click Yes --------------- Jacob Skaria "JohnM" wrote: Thanks Jacob, this worked great! It was soooooo much simpler than what I was trying to do in my script. -- JohnM "Jacob Skaria" wrote: Hi John Try the below and feedback Sub FindandReplace() Dim ws1 As Worksheet, ws2 As Worksheet Dim lngRow As Long Set ws1 = Worksheets("a") Set ws2 = Worksheets("b") For lngRow = 2 To ws1.Cells(Rows.Count, "B").End(xlUp).Row If Trim(ws1.Range("b" & lngRow)) < "" And _ Trim(ws1.Range("k" & lngRow)) < "" Then _ ws2.Columns("J:J").Replace What:=ws1.Range("B" & lngRow), _ Replacement:=ws1.Range("k" & lngRow), LookAt:=xlWhole, _ SearchOrder:=xlByRows, MatchCase:=False Next End Sub If this post helps click Yes --------------- Jacob Skaria "JohnM" wrote: I am trying use VBA to: locate the value that is in Sheet"a" column b, row 2 in Sheet"b" then replace value in Sheet"b", column J with value from Sheet"a" column K increment to Sheet"a" column b, row 3 Find matching value in Sheet"b" replace value in Sheet"b", column J with value from Sheet"a" column K Thanks in advance, -- JohnM |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find and Replace Sheet names | Excel Discussion (Misc queries) | |||
Find 0s on Sheet and Replace with Formula | Excel Programming | |||
Find/Replace Event or Find/Replace for Protected Sheet ... | Excel Programming | |||
find replace within sheet or workbook | Excel Programming | |||
trying to find #REF! in a formula to replace with a sheet name | Excel Programming |