advancedfilter blowing up with runtime error 1004

J

jjfjr

Hi;

I have a workbook with two sheets: Data and Results. My search button on
the results sheet when pressed will see what criteria has been entered in the
criteria section of Results and then display matches in Data in the Result
section of the Result sheet. I have the following declarations:

Dim MaxResults As Integer, MyCol As Integer, ResultsRng As String
Dim MyRow As Integer, LastDataRow As Integer, DataRng As String
Dim CritRow As Integer, CritRng As String, RightCol As Integer
Dim TopRow As Integer, BottomRow As Integer, LeftCol As Integer

CritRng = "B3:I5" ' range of cells for Criteria table
ResultsRng = "B8:I8" ' range of headers for Results table

Towards the end of the code is the following line:

Worksheets("Data").Range(DataRng).AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range(CritRng), CopyToRange:=Range(ResultsRng), _
Unique:=False

When it tries to execute, I get the following error:

Run-time error '1004':
The extract range has a missing or illegal field name.

Is this extract range in the Results sheet (criteria or results section?) or
the Data sheet? Any help is appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top