本帖最后由 qh8600 于 2015-1-2 09:01 编辑
- Sub demo()
- Dim ar, re(), xx, i, j, x, y
- ar = Range("b3:g" & Cells(Rows.Count, 2).End(3).Row)
- ReDim re(1 To UBound(ar), 1 To UBound(ar, 2) - 1)
- For i = 1 To UBound(ar)
- For j = 1 To UBound(ar, 2) - 1
- re(i, j) = Abs(ar(i, j) - ar(i, j + 1))
- Next
- For x = 1 To UBound(re, 2)
- For y = x + 1 To UBound(re, 2)
- If re(i, x) < re(i, y) Then
- xx = re(i, y)
- re(i, y) = re(i, x)
- re(i, x) = xx
- End If
- Next
- Next
- Next
- Range("k3").Resize(UBound(re), UBound(re, 2)) = re
- End Sub
复制代码 附件楼下
|