|
'估计差不多,自己试一下
Option Explicit
Sub test()
Dim arr, i, t, sum, n
arr = Range("h1:h" & Cells(Rows.Count, "h").End(xlUp).Row)
sum = [j1].Value: [k:k].ClearContents
For i = 1 To UBound(arr, 1)
t = Val(arr(i, 1))
If t > 99 Then
t = (t Mod 1000) \ 10
If t \ 10 + t Mod 10 = sum Then n = n + 1: arr(n, 1) = arr(i, 1)
End If
Next
If n = 0 Then Exit Sub
For i = 1 To n - 1
For j = i + 1 To n
If arr(i, 1) > arr(j, 1) Then
t = arr(i, 1): arr(i, 1) = arr(j, 1): arr(j, 1) = t
End If
Next j, i
[k1].Resize(n) = arr
End Sub |
|