• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find matching value in 2 different columns and copy data if match

Bruno125sx

New Member
Hi There,

can someone advise me on my code?

i want to find the matching value from B9:B100 Sh4 columns B14:B51 Sh 7.

when found, copy the cell +13 col of the found value row of Sh4 to cell + 3 of the found value row of Sh7.

my code isn't finished but it can't find match... and there is.

Cheers


Code:
Sub Addnametotimedata()


 Dim rng1 As Range, rng2 As Range, rngName As Range, i As Integer, j As Integer

 Sheet4.Select
    For i = 1 To Sheet4.Range("B9:B100").Row '& Rows.Count).End(xlUp).Row
        Set rng1 = Sheet4.Range("B9" & i)
       
    For j = 1 To Sheet7.Range("B14:B51").Row '.End(xlUp).Row
        Set rng2 = Sheet7.Range("B14" & j)
       
            If rng2 <> 0 Or rng1 <> 0 Then
           
            If rng1.Value = rng2.Value Then
            Set rngName = Sheet4.Range("B" & j + 14)
            MsgBox rng2.Cells
            MsgBox rng1.Cells
           
             End If    'rngName.Copy Destination:=Worksheets7.Range("E" & i + 3)
            End If

        Set rng2 = Nothing
    Next j
    Set rng1 = Nothing
 Next i
End Sub
 
Back
Top