- Sub test()
- Dim r%, i%
- Dim arr, brr
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:b" & r)
- ReDim brr(1 To UBound(arr), 1 To 1)
- For i = 1 To UBound(arr)
- If arr(i, 2) < 0 Then
- brr(i, 1) = 9 * 10 ^ 8 + arr(i, 2) * (-1)
- Else
- brr(i, 1) = 1 * 10 ^ 8 + arr(i, 2)
- End If
- Next
- .Range("c2").Resize(UBound(brr), 1) = brr
- .Range("a2:c" & r).Sort key1:=.Range("a2"), order1:=xlAscending, key2:=.Range("c2"), order2:=xlDescending, Header:=xlNo
- .Columns(3).ClearContents
- End With
- End Sub
复制代码 |