|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub paibu()
Dim i, j, k, z, m, n, irow
Dim arr, brr
irow = Sheets("1").[e65536].End(xlUp).Row
arr = Sheets("1").Range("e1:l" & irow)
For i = 2 To UBound(arr)
If arr(i, 6) <> 1 Then
arr(i, 5) = 100000
Else
arr(i, 5) = arr(i, 4)
End If
Next
j = 3
m = arr(3, 5)
For k = 3 To UBound(arr)
If arr(k, 5) < m Then
j = k
m = arr(k, 5)
End If
Next
ReDim brr(1 To irow - 1, 1 To 2)
brr(j - 1, 1) = arr(j, 1)
arr(j, 7) = arr(j, 1)
brr(j - 1, 2) = arr(j, 2)
arr(j, 8) = arr(j, 2)
If j > 51 Then
For z = 1 To Int((j - 1) / 50)
brr(j - 50 * z - 1, 1) = arr(j - 50 * z, 1)
brr(j - 50 * z - 1, 2) = arr(j - 50 * z, 2)
Next
End If
If irow - j >= 51 Then
For z = 1 To Int((irow - j) / 50)
brr(j + 50 * z - 1, 1) = arr(j + 50 * z, 1)
brr(j + 50 * z - 1, 2) = arr(j + 50 * z, 2)
Next
End If
Sheets("1").[k2].Resize(UBound(brr), 2) = brr
For n = 1 To irow - 1
If brr(n, 1) <> "" Then
Sheets("1").Cells(n + 1, 11).Resize(1, 2).Interior.Color = vbGreen
End If
Next
End Sub |
|