pls。 SO
Sub test()
Dim data() As String
Dim i As Long
Dim dd As Long
Dim lastrow As Variant
Dim lastcolumn As Variant
Dim status As Boolean
lastrow = Range("A" & Rows.Count).End(xlUp).Row
lastcolumn = Cells(2, Columns.Count).End(xlToLeft).Column
ReDim data(lastrow - 1, lastcolumn)
For i = 2 To lastrow
For j = 1 To lastcolumn
data(i - 1, j) = Cells(i, j)
Next j
Next i
For i = 1 To lastrow - 1
Call similarity(data(), i)
Next i
End Sub
Public Function similarity(rdata() As String, currrow As Long)
lastrow = UBound(rdata)
matchcount = 0
lastcolumn = UBound(rdata, 2)
For Z = currrow To lastrow - 1
ReDim test(lastcolumn) As String
ReDim test1(lastcolumn) As String
For i = 1 To lastcolumn
test(i) = rdata(currrow, i)
test1(i) = rdata(Z + 1, i)
Next i
Call sort(test())
Call sort(test1())
For i = 1 To lastcolumn
If test(i) = test1(i) Then
matchcount = matchcount + 1
End If
Next i
If matchcount = lastcolumn Then
If Cells(currrow + 1, lastcolumn + 1).Value <> "" Then
Cells(currrow + 1, lastcolumn + 1).Value = Cells(currrow + 1, lastcolumn + 1).Value & "|" & "Match with " & Z + 2
Else
Cells(currrow + 1, lastcolumn + 1).Value = "Match with " & Z + 2
End If
If Cells(Z + 2, lastcolumn + 1).Value <> "" Then
Cells(Z + 2, lastcolumn + 1).Value = Cells(Z + 2, lastcolumn + 1).Value & "|" & "Match with " & currrow + 1
Else
Cells(Z + 2, lastcolumn + 1).Value = "Match with " & currrow + 1
End If
End If
matchcount = 0
Next Z
End Function
Sub sort(list() As String)
Dim First As Integer, Last As Long
Dim i As Long, j As Long
Dim temp As String
First = LBound(list)
Last = UBound(list)
For i = First To Last - 1
For j = i + 1 To Last
If list(i) > list(j) Then
temp = list(j)
list(j) = list(i)
list(i) = temp
End If
Next j
Next i
End Sub
へようこそ下記のコードを入力して試してください。これは無料のコード作成サービスではありません。しかし、私たちは、同僚のプログラマー(および志望者)を**その**コードで支援することを熱望しています。 [良い質問をするにはどうすればいいですか?](http://stackoverflow.com/help/how-to-ask)のヘルプトピック、および[最小限の、完全で検証可能な例](http ://stackoverflow.com/help/mcve)。その後、達成したいタスクを完了するために、これまでに書いたVBAコードで質問を更新してください。 – Ralph