Filter

K

kevin carter

Hi
We have the following code that filters a range in database(no problem)
this code is looking at column A which is a week number(11)
what we now need to do is extend this code to filter two ranges
the second range is column H and is days of the week(Monday)

Is it possible to expand this code to do this?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 2 And Target.Column = 3 Then
Sheets("data2").Range("Criteria").Calculate
Worksheets("data2").Range("Database") _
.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("data2").Range("Criteria"), _
CopyToRange:=Range("A6:i6"), Unique:=False
Sheets("Data Entry").Range("D2").Calculate
End If
End Sub

thanks in advance

Kevin
 
D

Debra Dalgleish

Change your Criteria range to include both fields

Then, you'd need a second cell in which to choose the criterion for the
Weekday field.

In the code, check for both addresses, e.g.:

If Target.Address = "$C$2" Or Target.Address = "$D$2" Then
 
K

kevin carter

Debra Dalgleish said:
Change your Criteria range to include both fields

Then, you'd need a second cell in which to choose the criterion for the
Weekday field.

In the code, check for both addresses, e.g.:

If Target.Address = "$C$2" Or Target.Address = "$D$2" Then

thanks for reply the code a treat

however this is not returning the results we were hoping for
at present this returns all the occurences of both conditions
what we now need to do is filter the data on a time value and day
ie 06: - 07:00 and Tuesday
only the occurances of this condition should be returned

Can you help please

kevin
 
D

Debra Dalgleish

If the criteria range has both fields on the same row, the filter should
only return records where both criteria are met.
 

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

Similar Threads

Duplicate a code 4
macro add 10
relative destination for advance filter results 1
Filter and copy question 3
Advance Filter 5
copyToColumn 1
Migrating to Excel 2007 2
xlfiltercopy and formatting 0

Top