|
EPONE的SHEET2是否也要从第一行开始,清空原有内容?- Sub test1()
- Dim rg As Range, rg2 As Range
- Dim lLastRow As Long
- Dim arr
- On Error Resume Next
- If TypeName(Selection) <> "Range" Then MsgBox "选择的非单元格区域": Exit Sub
-
- Set rg = Selection
- With Worksheets("sheet2")
- .UsedRange.Clear
- For Each rg2 In rg.Areas
- arr = rg2.Value
- lLastRow = 1
- With .Cells(lLastRow, 1)
- If IsArray(arr) Then
- .Resize(UBound(arr), UBound(arr, 2)).Value = arr
- Else
- .Value = arr
- End If
- End With
- lLastRow = .Cells(Rows.Count, 1).End(xlUp).Row + 1
- Next
- End With
- MsgBox "复制完成"
- End Sub
复制代码 |
|