And perhab you can change to this
I am sorri not test
Or another idea
'b,e,h
Sub xxx (r as range,sh as string)
Dim dic As Object, t$, k, i&, sp, ii&, sp1$, lr&
Set dic = CreateObject("scripting.dictionary")
Sheets(sh).Activate
x = r.Value
For i = 1 To UBound(x)
t = x(i, 1) & ";" & x(i, 2)
sp = Split(t, ";")
For ii = 0 To UBound(sp)
If Not dic.exists(Trim$(sp(ii))) Then
dic(sp(ii)) = sp(ii)
Else
dic(sp(ii)) = dic(Trim$(sp(ii))) & "," & Trim$(sp(ii))
End If
Next ii
For Each k In dic.keys
If InStr(dic(k), ",") Then
sp1 = IIf(sp1 = "", k, sp1 & ";" & k)
End If
Next k
x(i, 3) = sp1
sp1 = "": sp = "": dic.RemoveAll
Next i
r.columns(3).offset(1).Resize(r.rows
Count-1) = Application.Index(x, 0, 3)
End Sub
In other code you can call
Sub tesss()
Dim lr as long
lr = activesheet.usedrange.specialcells(11).row
xxx Sheets("Example").range("b2:d" & lr),"Example"
'second range
xxx sheets("Example").range("e2:g" & lr),"Example"
'third range etc
Bookmarks