LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Advancedfilter returning all rows instead of ones that match crit

Hi;

I have a workbook with two sheets: Data and Results. My search button on
the Results sheet will see what criteria has been entered in the
criteria section of Results and then display rows in the Data sheet that
match the Criteria. The matching rows are displayed 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

DataRng = "$A$2:$H$9" 'range of cells to searched on the data sheet
CritRng = "$B$3:$I$3" ' range of cells for Criteria table
ResultsRng = "$B$9:$I$1000" ' 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:=True

Instead of returning only the rows in the "Data" sheet that match the
criteria range, all rows in "Data" are returned to the Results section of the
Results sheet. DataRng ,CritRng and ResultsRng all seem to have the proper
values. This occurs whether I set Unique in the AdvancedFilter statement to
true or false.

Any help is greatly appreciated.
--
JJFJR
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Match returning #N/A Frank Pytel Excel Worksheet Functions 7 November 4th 08 07:14 PM
index match array function-returning only first match, need last. Julie Olsen Excel Worksheet Functions 3 December 29th 06 12:50 AM
Count the number of rows where more than one column meets set crit BarrieVoice Excel Worksheet Functions 2 July 14th 06 07:25 PM
How to use AdvancedFilter wildcard to match end of string? bereid Excel Discussion (Misc queries) 2 November 29th 05 02:09 AM
How to count rows in a user-defined AutoFilter or AdvancedFilter is active? Frank Krogh Excel Programming 1 February 26th 04 11:08 AM


All times are GMT +1. The time now is 06:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"