可以用如下代码实现:
Sub pailie()
c = WorksheetFunction.CountA(Range("A:A"))
n = ActiveSheet.Name
cl = 2
For x = 1 To c
a1 = Range("A" & x)
a1l = Left(a1,WorksheetFunction.find(",",a1) - 1)
a1r = Right(a1,WorksheetFunction.find(",",a1) - 1)
For y = x + 1 To c
a2 = Range("A" & y)
a2l = Left(a2,WorksheetFunction.find(",",a2) - 1)
a2r = Right(a2,WorksheetFunction.find(",",a2) - 1)
If a1l = a2l Or a1l = a2r Then GoTo yy
If a1r = a2l Or a1r = a2r Then GoTo yy
For z = y + 1 To c
a3 = Range("A" & z)
a3l = Left(a3,WorksheetFunction.find(",",a3) - 1)
a3r = Right(a3,WorksheetFunction.find(",",a3) - 1)
If a1l = a3l Or a1l = a3r Then GoTo zz
If a1r = a3l Or a1r = a3r Then GoTo zz
If a2l = a3l Or a2l = a3r Then GoTo zz
If a2r = a3l Or a2r = a3r Then GoTo zz
Sheets(n).Cells(1,cl) = a1
Sheets(n).Cells(2,cl) = a2
Sheets(n).Cells(3,cl) = a3
cl = cl + 1
zz:
Next z
yy:
Next y
Next x
End Sub
运行时一定要注意选择当前表,可以在A列增加或改动数据,但格式要与现在保持一致,即"X,Y"的格式