收到错误的行是:
If rngT1 = Range("A2:D2") Then
这是完整的子程序:
Sub Copy_and_Paste_Other_Expenses()
'Copy Expense into the Payroll Journal
Dim rngT1 As Range
'Set the worksheet name and range appropriately
Set rngT1 = Range(ActiveSheet.Range("A2"), ActiveSheet.Range("D2").End(xlDown))
'Paste other expense in in payroll Journal
If rngT1 = Range("A2:D2") Then
rngT1.Copy
ActiveWorkbook.Sheets("Payroll Journal").Range("N43:Q43").PasteSpecial xlPasteValues
ElseIf rngT1 <> ActiveWorkbook.Sheets("dat.").Range("A2:D2") Then
rngT1.Copy
ActiveWorkbook.Sheets("Payroll Journal").Range("N43:Q46").PasteSpecial xlPasteValues
End If
Rows("1:1").Select
'Turn off Filter
Selection.AutoFilter
End Sub
答案 0 :(得分:1)
您无法比较那样的数组(这是您隐式执行的操作,因为Range.Value是范围的默认属性)。
不完全确定你要做什么,但是如果你试图检查两个引用是否指的是你可以做的相同范围
If Range1.Address = Range2.Address Then...