J
jjfjr
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.
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.