The line that is recieving the error is:
If rngT1 = Range("A2:D2") Then
This is the full subroutine:
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
You cannot compare Arrays like that (which is what you are implicitly doing as Range.Value is the default property of a range).
Not entirely sure what you are trying to do, but if you are trying to check that the two references refer to the same range you can do
If Range1.Address = Range2.Address Then...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.