abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,460
- Office Version
- 2019
- 2010
- Platform
- Windows
hello
I try matching data based on column B in sheet1 with column A in sheet2 and copy data from column K : U in sheet1 to column H:R in sheet2
I want fix this code ,please?
I try matching data based on column B in sheet1 with column A in sheet2 and copy data from column K : U in sheet1 to column H:R in sheet2
I want fix this code ,please?
VBA Code:
Sub match_copy()
Dim lRow, x As Long, ws As Worksheet
Set ws = Sheets("Sheet1")
lRow = ws.Range("B1").End(xlDown).Row
For Each cell In Range("B2:B" & lRow)
x = 2
Do
If cell.Value = Sheets("Sheet2").Cells(x, "A").Value Then
Sheets("Sheet2").Cells(x, "H").Value = cell.Resize(, 19).Value
End If
x = x + 1
Loop Until IsEmpty(Sheets("Sheet2").Cells(x, "A"))
Next
Sheets("Sheet2").Activate
End Sub