|
请测试
Sub Macro1()
Dim arr, brr(), crr(), temp$, i&, m%, n%, s1$, s2$
s1 = "" & [b3]
s2 = "" & [c3]
arr = Range("A4:A" & Range("A65536").End(xlUp).Row)
For i = 1 To UBound(arr)
temp = Format(arr(i, 1), "00")
If Left(temp, 1) = s1 Then
m = m + 1
ReDim Preserve brr(1 To m)
brr(m) = arr(i, 1)
End If
If Right(temp, 1) = s2 Then
n = n + 1
ReDim Preserve crr(1 To n)
crr(n) = arr(i, 1)
End If
Next
ActiveSheet.UsedRange.Offset(2, 1).Clear
With Range("B4").Resize(m)
.Value = WorksheetFunction.Transpose(brr)
.Sort Key1:=Range("B4").Resize(m), Order1:=xlAscending
End With
With Range("c4").Resize(n)
.Value = WorksheetFunction.Transpose(crr)
.Sort Key1:=Range("c4").Resize(n), Order1:=xlAscending
End With
Range("B4").Resize(UBound(arr), 2).NumberFormatLocal = "00"
End Sub |
|