Sub Test()
Dim a, b, c As New Collection, i As Long, j As Long, r As Object, strKey As String, v, w1, w2
With Sheets("Sheet1")
a = .Range("A1").CurrentRegion.Value
Set r = CreateObject("VBScript.RegExp")
r.Global = True
r.IgnoreCase = True
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.Pattern = "([AEIOU])"
For j = 1 To UBound(a, 2)
For i = 1 To UBound(a, 1)
If Len(a(i, j)) Then
strKey = .Replace(a(i, j), "")
On Error Resume Next
c.Add Key:=strKey, Item:=Array(New Collection, New Collection)
On Error GoTo 0
c(strKey)(j - 1).Add a(i, j)
End If
Next i
Next j
ReDim b(1 To UBound(a, 1), 1 To UBound(a, 2))
i = 0
For Each v In c
If v(0).Count * v(1).Count Then
For Each w1 In v(0)
r.Pattern = .Replace(w1, "$1+")
For Each w2 In v(1)
If r.Test(w2) Then
i = i + 1
b(i, 1) = w1
b(i, 2) = w2
End If
Next w2
Next w1
End If
Next v
End With
If i Then .Range("G1").Resize(i, 2).Value = b
End With
End Sub
Bookmarks