Sub test()
Dim dic As Object, wks As Worksheet, t As Integer
Set dic = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
For x = 1 To Sheets.Count
If Sheets(x).Name = "Result" Then
Application.DisplayAlerts = False
Sheets(x).Delete
Application.DisplayAlerts = True
Exit For
End If
Next
Sheets("VoorVBA").Copy After:=Sheets(Sheets.Count): Sheets(Sheets.Count).Name = "Result"
Set wks = Sheets("Result")
With wks
For x = 2 To .Range("J" & Rows.Count).End(xlUp).Row
If .Range("J" & x) <> "Faciliteit-ID" And Range("J" & x) <> vbNullString Then
.Range("K" & x) = .Range("J" & x) & "-" & Application.CountIf(.Range("J1", "J" & x), "Faciliteit-ID")
End If
Next
For nrow = 2 To .Cells(Rows.Count, "K").End(xlUp).Row
If Not IsEmpty(.Cells(nrow, "K")) Then
If (Not dic.exists(.Cells(nrow, "K").Value)) Then
dic.Add .Cells(nrow, "K").Value, .Cells(nrow, "K").Value
End If
End If
Next
arr = dic.keys
lr = .Range("K" & Rows.Count).End(xlUp).Row
For i = 0 To UBound(arr) - 1
For Each cl In .Range("K2", "K" & lr)
If cl = arr(i) Then
j = j + 1
If j = 1 Then myrow = cl.Row
If j > 1 Then
.Range("A" & myrow) = .Range("A" & myrow) & "-" & .Range("A" & cl.Row)
If InStr(1, .Range("B" & myrow), .Range("B" & cl.Row)) = 0 Then .Range("B" & myrow) = .Range("B" & myrow) & "-" & .Range("B" & cl.Row)
If InStr(1, .Range("C" & myrow), .Range("C" & cl.Row)) = 0 Then .Range("C" & myrow) = .Range("C" & myrow) & "-" & .Range("C" & cl.Row)
If InStr(1, .Range("E" & myrow), .Range("E" & cl.Row)) = 0 Then .Range("E" & myrow) = .Range("E" & myrow) & "-" & .Range("E" & cl.Row)
.Range("I" & myrow) = .Range("I" & myrow) + .Range("I" & cl.Row)
.Range("I" & cl.Row).Resize(, 3).ClearContents
End If
End If
Next
j = 0
Next
.Columns.AutoFit
.Range("K:K").ClearContents
.Columns("J").SpecialCells(4).EntireRow.Delete
End With
Application.Goto Range("A1"), scroll:=True
End Sub