Harshil Mehta
Board Regular
- Joined
- May 14, 2020
- Messages
- 85
- Office Version
- 2013
- Platform
- Windows
I want to check if the ID in sheet No.2, column B (Refer attached) is present in sheet No. 3, column B and copy the difference to sheet No.5, Range B11 along with NAME, COUNTRY, REGION & SECTOR.
The below code only copies the ID to sheet No.5, Range B11.
I want to edit the code that copies ID, NAME, SECTOR, COUNTRY & REGION to sheet No.5
Please help me with the above code.
The below code only copies the ID to sheet No.5, Range B11.
I want to edit the code that copies ID, NAME, SECTOR, COUNTRY & REGION to sheet No.5
VBA Code:
Sub x()
Dim v1, v2, v3(), i As Long, j As Long
v1 = Sheet2.Range("B11", Sheet2.Range("B" & Rows.Count).End(xlUp)).Value
v2 = Sheet3.Range("B11", Sheet3.Range("B" & Rows.Count).End(xlUp)).Value
ReDim v3(1 To UBound(v1, 1))
For i = LBound(v1) To UBound(v1)
If IsError(Application.Match(v1(i, 1), v2, 0)) Then
j = j + 1
v3(j) = v1(i, 1)
End If
Next i
Sheet5.Range("B11").Resize(j) = Application.Transpose(v3)
End Sub
Please help me with the above code.