|
Sub test()
Dim A, i
Sheets(1).Select
Range("b:b").ClearContents
A = Range("A1:B" & Cells(Rows.Count, 1).End(xlUp).Row)
For i = 7 To UBound(A)
A(i, 2) = f(A, i - 1, 2)
Next i
Sheets(2).Select
Range("b:b").NumberFormat = "@"
Cells.ClearContents
Range("a1").Resize(UBound(A), UBound(A, 2)) = A
End Sub
Function f(A, x, y)
Dim B(9), i, s, temp, num
For i = x To y Step -1
If s = 3 Then Exit For
num = A(i, 1)
If B(num) = "" Then
B(num) = num
s = s + 1
temp = temp & num
ElseIf B(num) <> num Then
s = s + 1
temp = temp & num
End If
Next i
f = IIf(s < 3, -1, temp)
End Function
2.rar
(730.25 KB, 下载次数: 1)
|
|