PDA

View Full Version : Runtime error while using Advanced filter



umasriram2
01-22-2009, 10:49 AM
I’m building a macro that can do an advanced filter and copy the resultant in another sheet. However I get a run time error 1004 in the filtering line. Could you please help? Here is my code

Sub filter()
Dim crit As Range
Dim rng As Range
Worksheets("criteria").Select
Set crit = Sheets("criteria").Range("A2", Range("A2").End(xlDown))
Sheets("Unprocessed").Select
Set rng = Sheets("Unprocessed").Range("A1", Range("A1").End(xlDown).End(xlToRight))
Cells.Select
Range(rng).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Sheets( _
"criteria").Range(crit), Unique:=False
ActiveWindow.SmallScroll Down:=-42
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Sheets("criteria").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "Processed"
Range("B8").Select
Sheets("Sheet5").Select
Sheets("Sheet5").Name = " Processed "
Range("I18").Select
Sheets("Unprocessed").Select
Cells.Select
ActiveSheet.ShowAllData
ActiveWorkbook.Save
End Sub


Edit Lucas: vba tags added to code. You can select your code when posting and hit the vba button to format your code for the forum.

lucas
01-22-2009, 11:01 AM
Your criteria seems to be a column. Can you post your workbook without any personal info or an example and show us before and after so we can see what you are trying to do?

hit post reply in the lower left of the last post, after entering your message, scroll down and look for the button that says "manage attachments"

umasriram2
01-23-2009, 04:00 AM
Here you go...The "Unprocessed" sheet is where I have all the data and I'm trying to segregate the data in to sheets depending on the status mentioned in Col.E