|
本帖最后由 exlover 于 2013-10-21 23:23 编辑
求助可否办到。
- Sub test1()
- Dim rg As Range, rg2 As Range
- Dim lLastRow As Long
- Dim arr
- On Error Resume Next
- Set rg = Application.InputBox("请选择要复制的多区域", Type:=8)
- If Err.Number <> 0 Then Exit Sub
- With Worksheets("sheet3")
- lLastRow = .Cells(Rows.Count, 1).End(xlUp).Row + 2
- For Each rg2 In rg.Areas
- arr = rg2.Value
- 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
- Sub test2()
- Dim rg As Range, rg2 As Range
- Dim lLastRow As Long
- Dim arr
- On Error Resume Next
- Set rg = Application.InputBox("请选择要复制的多区域", Type:=8)
- If Err.Number <> 0 Then Exit Sub
- With Worksheets("sheet3")
- For Each rg2 In rg.Areas
- arr = rg2.Value
- lLastRow = .Cells(Rows.Count, 1).End(xlUp).Row + 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
复制代码
|
|