|
本帖最后由 yjh_27 于 2014-2-9 21:52 编辑
hubulwm 发表于 2014-2-9 21:15
感谢yjh_27 和zax010 的程序,两位的程序均能实现预想的格式,一旦序列改变,程序就不适应了。现在的问题是 ...
哪不是问题,但是输入输出的首单元格你还是指定。- Sub aa()
- Dim brr()
- col = Range("a2").End(xlToRight).Column '首列不在a,需减相应列数(如c为首列,-2)
- arr = Range("a2").Resize(1, col)
- maxi = arr(1, 1)
- mini = arr(1, 1)
- For i = 3 To UBound(arr, 2) Step 2
- If maxi < arr(1, i) Then maxi = arr(1, i)
- If mini > arr(1, i) Then mini = arr(1, i)
- Next
- ReDim brr(UBound(arr, 2) / 2, mini To maxi)
- For i = 1 To UBound(arr, 2) Step 2
- brr(0, arr(1, i)) = brr(0, arr(1, i)) + 1
- brr(brr(0, arr(1, i)), arr(1, i)) = arr(1, i + 1)
- Next
- ii = 0
- For i = 1 To UBound(brr, 1)
- For j = LBound(brr, 2) To UBound(brr, 2)
- If brr(0, j) > 0 Then
- arr(1, 2 * ii + 1) = j
- arr(1, 2 * ii + 2) = brr(i, j)
- ii = ii + 1
- brr(0, j) = brr(0, j) - 1
- End If
- Next
- Next
- Range("a5").Resize(1, UBound(arr, 2) ) = arr
- End Sub
复制代码
|
|