I wrote some comments hoping to clarify your doubts.

**ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))**
The matrix 'b' is resized to receive the "possible" result, with a total of rows from the matrix 'a' UBound (a,

**1**) and the number of columns from the same matrix 'a' UBound(a,

**2**).

I mean "possible" results, because they can be the same number of rows in the matrix 'a' in the case of no duplicates. Or it can be fewer rows, if there are duplicates. In either case, the matrix 'b' must be sized to receive the maximum number of rows.

_____________________________________________________________

**j = dic(a(i, 1) & "|" & a(i, 3))**
To explain that line, I must go back in the code.

VBA Code:

```
If Not dic.exists(a(i, 1) & "|" & a(i, 3)) Then
j = j + 1
dic(a(i, 1) & "|" & a(i, 3)) = j
```

If the index of the data in columns 1 "|" 3, does not exist, then two pieces of data are stored in the dictionary, the key that contains the data in columns 1 "|" 3 and the value of j.

At the beginning j is equal to 0, then there is the line:

j = j + 1

j = 0 + 1

j = 1

so the item for the key is 1

That means, in the logic of this code, that in row 1 we have the first key

So, let's see what happens if the key of the data in columns 1 "|" 3 already exist.

**j = dic(a(i, 1) & "|" & a(i, 3))**
With that statement I retrieve the row number according to the index of the data in columns 1 "|" 3.

Let's run the code to make it more understandable

**First time:**
not exists

j = j +1

j = 0 + 1

j = 1

key = "agent one|20110"

item = 1

b(1, 5) = "the text in this cell"

**Second time:**
exists

j = dic(a(i, 1) & "|" & a(i, 3))

j = 1

b(1, 5) = b(1, 5) & " " & "is suppose to be"

b(1, 5) = "the text in this cell" & "is suppose to be"

...

**fifth time**
not exists

j = j +1

j = 1 + 1

j = 2

key = "agent one|20025"

item = 2

b(2, 5) = "text one"

**sixth time:**
exists

j = dic(a(i, 1) & "|" & a(i, 3))

I retrieve the item stored in the dictionary according to the data

j = 2

b(2, 5) = b(2, 5) & " " & "text two"

b(2, 5) = "text one" & "text two"

I hope it helps.