Match Cell Data Based on Cell Value and Iterate Down Rows

Hello_World_Print

New Member
Joined
Jun 15, 2022
Messages
3
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
PLEASE NEED HELP

I have a sheet ("Sheet D") with different column headings from ("Sheet A") except for a part numbers column. I need to be able to go to ("Sheet D") and iterate down each row for the part number and find the matching part number in ("Sheet A"). If the part number from ("Sheet D") is found in ("Sheet A"), I need to copy that entire row where it was found and paste it into ("Sheet D") starting in column K. If the part number is not found in ("Sheet A"), I want it to skip that row in ("Sheet D") and leave it blank and move to the row below it and repeat. So far, I have this code but it doesn't work:

VBA Code:
Sub Excel()

Dim N As Long
Dim i As Long
Dim j As Long
SN As Range
SNRow As Long

With Worksheets("Sheet A").Columns("A")
        N = Cells(Rows.Count, "A").End(xlUp).Row
        
        For i = 2 To N
              For j = 2 To N
                    Set SN = .Find(Worksheets("Sheet D").Cells(i, "A").Value, LookIn:=xlValues)
                    If SN Is Nothing Then
                            GoTo NextIteration
                    Else
                    SNRow = SN.Row
                    Range(Sheets("Sheet A").Cells(SNRow, 1), Sheets("Sheet A").Cells(SNRow, 10)).Copy Range(j, "K")
                    End If
NextIteration:
               Next j
        Next i

End With
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,214,786
Messages
6,121,546
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top