|
发表于 2013-12-7 12:37
|
显示全部楼层
本楼为最佳答案
- Option Base 1
- Function 组合数据(sRng As Range, tRng As Range)
- Dim x%, y%, i%, m%, n%
- Dim sArr(), tArr()
- sArr = sRng
- For y = 1 To 3
- For x = 1 To UBound(sArr, 1)
- For m = y To y + 7
- If sArr(x, m) = "" Then
- n = n + 1
- ReDim Preserve tArr(1 To 10, 1 To n)
- For i = 1 To 10
- If i = m Then tArr(i, n) = m Else tArr(i, n) = sArr(x, i)
- Next i
- Exit For
- End If
- Next m
- Next x
- Next y
- tRng.Resize(n, 10) = Application.Transpose(tArr)
- 'sRng.Copy
- 'tRng.Resize(n, 10).PasteSpecial Paste:=xlPasteFormats
- End Function
- Sub 生成数据()
- tms = Timer
- Range("Y2:AS6000").Clear
- 组合数据 Range(Cells(2, 1), Cells(17, 10)), Range("Y2")
- 组合数据 Range(Cells(2, 12), Cells(17, 21)), Range("AJ2")
- MsgBox Format(Timer - tms, "0.000s ")
- End Sub
复制代码 我电脑上0.066秒 |
评分
-
查看全部评分
|