Hello_World_Print
New Member
- Joined
- Jun 15, 2022
- Messages
- 3
- Office Version
- 2013
- 2010
- Platform
- 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:
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