将数据从一个范围复制到另一个工作表范围

时间:2014-09-14 06:22:42

标签: excel vba excel-vba spreadsheet

问:我想将一些2列数据复制到另一张特定范围的表格中。请帮忙。提前谢谢。

Sub cutpaste()
    Range("c5:d7").Cut Sheets("C:\Users\Sai\Desktop\Anil peddi\Practice.xlsm\sheet2")range("f5")
End Sub

1 个答案:

答案 0 :(得分:1)

Sub myMacro()

    ' source
    Dim wbkSour As Workbook
        Set wbkSour = Workbooks("WorkBookNameWhereMacroIs.xlsm")

    ' destination
    Dim wbkDest As Workbook
        Set wbkDest = Workbooks.Open("C:\...\DestinationWorkBookName.xlsm")

    ' copying proccess
    wbkDest.Sheets("Sheet2").Range("F5:G7").Value = wbkSour.Sheets("Sheet1").Range("C5:D7").Value

    ' save and close destination
    wbkDest.Save
    wbkDest.Close

End Sub