|
自己写的- Sub test()
- Dim r%, i%, c%, j%
- Dim arr, brr
- '选定区域
- With Worksheets(1)
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:f" & r) 'f代表列共有f列 根据实际情况修改
- End With
-
- '根据区域设定需要装下新生成的区域大小
- ReDim brr(1 To 2 * UBound(arr), 1 To UBound(arr, 2))
-
- '把数组arr从第二条开始一条装目录一条装数据到数组brr中去
- m = 0
- For i = 2 To UBound(arr)
-
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(1, j)
- Next
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
-
- Next
-
- With Worksheets(2)
- .Cells.ClearContents
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- .Activate
- End With
-
- End Sub
复制代码 |
|