嗨,我有以下代码,其第一部分工作正常,但是我无法获得rng2的目标位-始终出现“应用程序定义或对象定义的错误”。我想知道是否有人可以通过尝试几种不同的方法来解决我的问题(目的地是我所了解的最简单的方法)。
Sub Assign_TN()
' Assign_TN Macro
Dim ws As Worksheet
Dim wbk2 As Workbook
Dim ws2 As Worksheet
Dim Rng As Range
Dim rng2 As Range
Set ws = ThisWorkbook.Worksheets("Check sheet")
Set wbk2 = Workbooks.Open("A Location\TNG Register ongoing.xlsx")
Set ws2 = wbk2.Worksheets("TNG")
'This clears the TN has failed comment in the event the cannot generate Tn macro has been run
ws.Range("A83").ClearContents
' Copy the first set of data from the checksheet and paste into the first blank row of the TNG register
Set Rng = ws.Range("B93:M93")
Rng.Copy Destination:=ws2.Cells(Rows.Count, 2).End(xlUp).Offset(1)
'copy second set of data from checksheet and paste into first blank cell in column 22
Set rng2 = ws.Range("Q93:AM93")
rng2.Copy
Destination = ws2.Cells(Rows.Count, 22).End(x1Up).Offset(0)
我要做的就是将两个范围数据复制到第二张工作表中第一个未填充行的两个单独区域中。实际上,这会生成一个接受号,然后将其复制并粘贴到第一张工作表中(这部分代码尚未添加且效果很好)。