1. ### Welcome to Chandoo.org Forums. Short message for you

Hi Guest,

Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

Yours,
Chandoo
2. 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...

3. 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

Discussion in 'VBA Macros' started by Bruno125sx, Mar 20, 2017.

1. ### Bruno125sxNew Member

Messages:
10
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 (vb):

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

2. ### PCosta87Well-Known Member

Messages:
870
Hi,

If possible upload a sample excel file so we can give a more targeted answer.

Thanks.
jamesexcel1970 likes this.
3. ### MontyWell-Known Member

Messages:
836
Bruno125sx

Question is not clear...Please upload a sample file with dummy data to test!
Arpanakumar and jamesexcel1970 like this.