|
不知道是否是你要的效果,请查看。
- Sub Main()
- Dim t
- Dim arr, i1, j1, k1
- Dim brr, i2, j2, k2
- t = Timer
- arr = Sheet1.UsedRange
- ReDim brr(1 To 100, 1 To 9)
- For i1 = 2 To UBound(arr, 1)
- i2 = i2 + 1
- For j1 = 1 To 9
- j2 = j1
- brr(i2, j2) = arr(i1, j1)
- Next j1
- For k1 = 10 To UBound(arr, 2) Step 2
- ' If k1 Mod 2 = 1 Then k2 = 7 Else k2 = 8 '总是成对出现
- k2 = 7
- If arr(i1, k1) <> "" Or arr(i1, k1 + 1) <> "" Then
- i2 = i2 + 1
- brr(i2, k2) = arr(i1, k1)
- brr(i2, k2 + 1) = arr(i1, k1 + 1)
- End If
- Next k1
- Next i1
- With Sheet3
- .[A2].Resize(i2, 9) = brr
- .Select
- End With
- Debug.Print Timer - t
- End Sub
复制代码 |
|