Hi,
I have set up the below to copy any rows which contain a matching PO value from one sheet and put them into another sheet in.
Every time I attempt to run I get an error message stating "Variable not defined" which then highlights "x1PasteValues". Not sure of what the issue was I set this as a variable but now receive the "PasteSpecial method of Range class failed".
When I take this back to basics and simply use
The macro works but the formatting issue still needs addressing.
Any assistance would be great. I've already tried using the basic copy then simply pasting the formatting from another part of the table but for some reason the Macro doesn't function then either.
I have set up the below to copy any rows which contain a matching PO value from one sheet and put them into another sheet in.
Code:
Sub InpInvExtSbc()
Dim oPO As String
Dim LR As Long, i As Long
oPO = Sheets("Input Invoice").Range("L9") & "-" & Range("L20")
With Sheets("External Subcontract")
LR = .Range("AT" & Rows.Count).End(xlUp).Row
For i = 1 To LR
If .Range("AT" & i).Value = oPO Then
Rows(i).Copy
Sheets("Input Invoice").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial x1PasteValues
End If
Next i
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Every time I attempt to run I get an error message stating "Variable not defined" which then highlights "x1PasteValues". Not sure of what the issue was I set this as a variable but now receive the "PasteSpecial method of Range class failed".
When I take this back to basics and simply use
Code:
.Range("AT" & i).Value = oPO Then Rows(i).Copy Destination:=Sheets("Input Invoice").Range("A" & Rows.Count).End(xlUp).Offset(1)
Any assistance would be great. I've already tried using the basic copy then simply pasting the formatting from another part of the table but for some reason the Macro doesn't function then either.