Sub Resetall()
Dim KZ As Worksheet
Dim VA As Worksheet
Dim ws As Worksheet
Dim iRow As Integer
Dim Rng As Range
Dim Aantal As Integer
Set ws = Worksheets("Data")
Set VA = Worksheets("HulpSheet")
Set KZ = Worksheets("Klanten")
Aantal = 0
lastRow = VA.Range("A:D").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For i = 2 To lastRow
For j = 1 To 5
VA.Cells(i,j).Value = ""
Next j
Next i
lastRow = ws.Range("C:C").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For i = 3 To lastRow
iRow = VA.Range("A:A").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If len(ws.Cells(i, 3).Value) > 1 then
Rng = VA.Range("A:A").Find(What:=ws.Cells(i, 3).Value, SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues)
If not Rng is Nothing then
Set Rng = Nothing
Else
VA.Cells(iRow, 1).Value = ws.Cells(i, 3).Value
End If
End If
Next i
lastRow = ws.Range("D:D").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For i = 3 To lastRow
iRow = VA.Range("B:B").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If len(ws.Cells(i, 4).Value) > 1 then
Rng = VA.Range("B:B").Find(What:=ws.Cells(i, 4).Value, SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues)
If not Rng is Nothing then
Set Rng = Nothing
Else
VA.Cells(iRow, 2).Value = ws.Cells(i, 4).Value
End If
End If
Next i
lastRow = ws.Range("E:E").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For i = 3 To lastRow
iRow = VA.Range("C:C").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If len(ws.Cells(i, 5).Value) > 1 then
Rng = VA.Range("C:C").Find(What:=ws.Cells(i, 5).Value, SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues)
If not Rng is Nothing then
Set Rng = Nothing
Else
VA.Cells(iRow, 3).Value = ws.Cells(i, 5).Value
End If
End If
Next i
lastRow = ws.Range("H:H").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
For i = 3 To lastRow
iRow = VA.Range("D:D").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If len(ws.Cells(i, 8).Value) > 1 then
Rng = VA.Range("D:D").Find(What:=ws.Cells(i, 8).Value, SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues)
If not Rng is Nothing then
Set Rng = Nothing
Else
VA.Cells(iRow, 4).Value = ws.Cells(i, 8).Value
End If
End If
Next i
Aantal = VA.Range("A:D").Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
KZ.Cells(3, 3).Value = ""
KZ.Cells(3, 4).Value = ""
KZ.Cells(3, 5).Value = ""
KZ.Cells(3, 6).Value = ""
KZ.Cells(6, 3).Value = ""
KZ.Cells(3, 8).Value = Aantal
Aantal = KZ.Cells.Find(What:=Aantal, SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1 'to get back on worksheet("Klanten")
End Sub
Bookmarks