'自己设置一下日期列格式(e列)
Option Explicit
Sub test()
Dim arr, i, j, k, kk, m, cnt
With Sheets("排序")
arr = .Range("a3:d" & .Cells(Rows.Count, "a").End(xlUp).Row + 1)
End With
For i = 1 To UBound(arr, 1) - 1
For j = i To UBound(arr, 1) - 1
If arr(j, 1) <> arr(j + 1, 1) Then
cnt = Round((j - i + 1) * 0.1, 0)
If cnt > 0 Then
For k = i To i + cnt - 1
m = m + 1
For kk = 1 To UBound(arr, 2): arr(m, kk) = arr(k, kk): Next
Next
End If
i = j: Exit For
End If
Next j, i
With Sheets("前10%债券").[e3]
.Resize(Rows.Count - 2, UBound(arr, 2)).ClearContents
If m > 0 Then .Resize(m, UBound(arr, 2)) = arr
End With
End Sub |