ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help to find and replace between sheets (https://www.excelbanter.com/excel-programming/442556-help-find-replace-between-sheets.html)

Eddy Stan

Help to find and replace between sheets
 
Hi all,
i have 2 sheets as below
column c J
row 6 511 285
row 7 285
row 8 422 625

sheet2 col b m
row 100 510
row 105 511 285
row 120 282
row 125 285
row 800 422 625

find sheet1 511 and 422 in sheet2 (because value next to them is 0) then
put next to them 285 and 625 in sheet2 from sheet1
thanks in advance

regards,
Eddy stan


PY & Associates[_2_]

Help to find and replace between sheets
 
On May 14, 4:59*am, Eddy Stan
wrote:
Hi all,
i have 2 sheets as below
column * * c * * * *J
row 6 * * *511 * *285
row 7 * * *285
row 8 * * *422 * *625

sheet2 * * * col b * m
row 100 * * *510
row 105 * * *511 * 285
row 120 * * *282 *
row 125 * * *285
row 800 * * *422 * 625

find sheet1 511 and 422 in sheet2 (because value next to them is 0) then
put next to them 285 and 625 in sheet2 from sheet1
thanks in advance

regards,
Eddy stan


something like this

Option Explicit
Sub m()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Worksheets("sheet1")
Set ws2 = Worksheets("sheet2")

Dim rng1 As Range
Dim rng2 As Range
Dim frow As Integer
Dim c As Range
Set rng1 = ws1.Range("C6:C8")
Set rng2 = ws2.Range("B100:B800")
On Error Resume Next

For Each c In rng1
If c.Offset(0, 7) 0 Then
frow = rng2.Find(c).Row
If frow 0 Then ws2.Cells(frow, "M") = c.Offset(0, 7)
frow = 0
End If
Next c
End Sub


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com