A guess:
If the code is in a sheet's code-module and that sheet is not the active sheet, you will get that error.
This is because an unqualified reference like Range("A:A,B:B,E:E,F:F,G:G,I:I,J:J,K:K,R:R") in a sheet's code-module always refers to that sheet. If it's not the active sheet it can't select that range.
To avoid the error:
Qualify the reference: Worksheets("Zplan_producao").Range("A:A,B:B,E:E,F:F,G:G,I:I,J:J,K:K,R:R") or Sheet3.Range("A:A,B:B,E:E,F:F,G:G,I:I,J:J,K:K,R:R") (here I've guessed the code name for that sheet).
Avoid selecting altogether, so instead of:use:Worksheets("Zplan_producao").Select ActiveSheet.ListObjects("Z_Plan_Oficial").Range.AutoFilter Field:=2, Criteria1:="=ABER"or instead of:Worksheets("Zplan_producao").ListObjects("Z_Plan_Oficial").Range.AutoFilter Field:=2, Criteria1:="=ABER"try:ActiveSheet.ListObjects("Z_Plan_Oficial").Range.AutoFilter Field:=2, Criteria1:="=ABER" Range("A:A,B:B,E:E,F:F,G:G,I:I,J:J,K:K,R:R").Select ' ----> ERROR Selection.Copy Sheets("Encomendas_em_aberto").Select Range("A1").Select ActiveSheet.PasteDoes the code have to be in a sheet's code-module?With Worksheets("Zplan_producao") .ListObjects("Z_Plan_Oficial").Range.AutoFilter Field:=2, Criteria1:="=ABER" .Range("A:A,B:B,E:E,F:F,G:G,I:I,J:J,K:K,R:R").Copy Sheets("Encomendas_em_aberto").Range("A1") End With
(Now you're going to tell me the code's not in a sheet's code-module!)




)

Reply With Quote
