Help to find and replace between sheets

E

Eddy Stan

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
 
P

PY & Associates

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top