Sub b()
Dim c As Range
Set Sh1 = Sheets("Blad1")
Set Sh2 = Sheets("Blad2")
Set sh3 = Sheets("Blad3")
repo = Sh2.Cells(1, 2)
Sh1.UsedRange.Copy sh3.Range("A1")
Set rng2 = Sh2.UsedRange.Resize(, 1).Offset(2, 0)
rng2.Select
With sh3
lastrow = .Range("A" & .Rows.Count).End(xlUp).Row
For j = 3 To lastrow
ID = .Cells(j, 1).Value
Set c = rng2.Find(ID, LookIn:=xlValues)
If Not c Is Nothing Then
.Cells(j, 4).Value = .Cells(j, 4).Value - Sh2.Cells(c.Row, 4).Value
.Cells(j, 5).Value = .Cells(j, 5).Value - Sh2.Cells(c.Row, 5).Value
.Cells(j, 6).Value = .Cells(j, 6).Value - Sh2.Cells(c.Row, 6).Value
End If
Next
End With
End Sub
Bookmarks