1
I need to make a filter with a certain value in a spreadsheet tab,after the filter is done, I need to copy, open a new document, and paste this statement.
I developed the code below but it’s not working.
follows the code
Sub filtrar()
Worksheets(Array("Planilha3", "Planilha2", "Planilha3",)).Copy
ActiveSheet.Range("Planilha3").AutoFilter Field:=Range("E1:E1048576").Column, Criteria1:="Cell 01"
With ActiveWorkbook
ActiveWorkbook.SaveAs Filename:=fname1, FileFormat:=xlOpenXMLWorkbookMacroEnabled
ThisWorkbook.Save
ThisWorkbook.Close
End With
End Sub
You use Spreadsheet 3 twice and have a window at the end. So the function expects 4 Sheets.
Worksheets(Array("Planilha3", "Planilha2", "Planilha3",)).Copy
. The right thing would beWorksheets(Array("Planilha1", "Planilha2", "Planilha3")).Copy
– danieltakeshi
@danieltakeshi thanks for the remark, but I was wrong to type
– John Hebert
o Error shown is : Runtime Error 1004
– John Hebert
In which line does the error occur? And I believe that
ActiveSheet.Range("Planilha3").AutoFilter
is wrong. You only want to filter column 3 of the new Datasheet for the data="Cell 01"
?– danieltakeshi
The error occurs in the Activesheet.Range line ("Planilla3"). Autofilter Field:=Range("E1:E1048576"). Column, Criteria1:="Cell 01"
– John Hebert
and on the filter that’s right, I want to search in the tab ( sheet 3) in column 3 the data = "Cell 01'
– John Hebert