首页 文章

如何控制位置以将一个工作表复制到另一个工作簿中

提问于
浏览
0

我有代码将原始工作簿的一个工作表复制到终止的工作簿,它工作正常 . 但我需要控制粘贴位置以终止工作簿 . 现在它在活动表之前粘贴 . 我希望它在我的摘要表之后进入第二张表 . 我是Macro的新手,谢谢 .

Sub CopytoTernimal()
Dim CopyName As String

On Error GoTo ErrMess

CopyName = InputBox("Please enter the name of sheet which will copy to ternimal")

Dim thisSheet As Worksheet

Set thisSheet = Workbooks("original.xlsm").Worksheets(CopyName)

thisSheet.Rows.Copy

Dim NewSheet As Worksheet
Set NewSheet = Workbooks("Terminated Employees.xlsm").Worksheets.Add()
NewSheet.Name = thisSheet.Name
NewSheet.Paste

thisSheet.Delete

ErrExit:退出Sub

ErrMess:MsgBox“xxxxxx . ” GoTo ErrExit

End Sub

1 回答

  • 1

    我相信它会是这样的

    thisSheet.Copy After:=Workbooks("Terminated Employees.xlsm").Worksheets("name of the first summary worksheet")
    

相关问题