给你一个代码,ALT+F11——F7——粘贴如下代码——调整格式(该换行的要换行)——F5运行代码。
但是没按你的要求。我是填在一行的。
Sub mysub()
Dim i As Long, j As Long
Columns("d:o").Cells.Clear
Columns("D:o").NumberFormatLocal = "@"
For i = 1 To [a65536].End(xlUp).Row
j = 4
Cells(i, j) = CStr(Cells(i, 1).Value) & CStr(Cells(i, 2).Value) & CStr(Cells(i, 3).Value)
j = j + 1
If Range(Cells(i, 4), Cells(i, 12)).Find(CStr(Cells(i, 1).Value) & CStr(Cells(i, 3).Value) & CStr(Cells(i, 2).Value)) Is Nothing Then
Cells(i, j) = CStr(Cells(i, 1).Value) & CStr(Cells(i, 3).Value) & CStr(Cells(i, 2).Value)
j = j + 1
End If
If Range(Cells(i, 4), Cells(i, 12)).Find(CStr(Cells(i, 2).Value) & CStr(Cells(i, 1).Value) & CStr(Cells(i, 3).Value)) Is Nothing Then
Cells(i, j) = CStr(Cells(i, 2).Value) & CStr(Cells(i, 1).Value) & CStr(Cells(i, 3).Value)
j = j + 1
End If
If Range(Cells(i, 4), Cells(i, 12)).Find(CStr(Cells(i, 2).Value) & CStr(Cells(i, 3).Value) & CStr(Cells(i, 1).Value)) Is Nothing Then
Cells(i, j) = CStr(Cells(i, 2).Value) & CStr(Cells(i, 3).Value) & CStr(Cells(i, 1).Value)
j = j + 1
End If
If Range(Cells(i, 4), Cells(i, 12)).Find(CStr(Cells(i, 3).Value) & CStr(Cells(i, 1).Value) & CStr(Cells(i, 2).Value)) Is Nothing Then
Cells(i, j) = CStr(Cells(i, 3).Value) & CStr(Cells(i, 1).Value) & CStr(Cells(i, 2).Value)
j = j + 1
End If
If Range(Cells(i, 4), Cells(i, 12)).Find(CStr(Cells(i, 3).Value) & CStr(Cells(i, 2).Value) & CStr(Cells(i, 1).Value)) Is Nothing Then
Cells(i, j) = CStr(Cells(i, 3).Value) & CStr(Cells(i, 2).Value) & CStr(Cells(i, 1).Value)
j = j + 1
End If
Next
End Sub