Advanced Filter problem

R

R. Choate

This seems simple but I guess I'm more simple than the problem today. I have a basic list with a column of dates. The dates are the
results of formulas and are formatted as yyyymm. Some of the formulas don't yield a date and so those cells display nothing. The
dates that are displayed might actually be any date within a month, just formatted as described. So far so good. However, I need my
advanced filter to only show the rows which contain a date that is in the same month as a cell that is not in the table. That cell
is formatted like the ones in the table and also may be any day of any month. I was able to tinker with the criteria enough to get
it to show only rows in April 06 when my control cell has an April 06 date, but if I changed the control date to a different day in
a different month it wouldn't show any rows at all. Then if I changed it back to the original control date in April 06 it still
wouldn't show any rows. This is messed up. Plz help.

Richard
 
A

Ardus Petus

Say your dates are in column A, and your control date is in D1

Criterion header: empty
Criterion:
=MONTH(A2)=MONTH(D1)

NB: The formatting of your cells has no incidence on the operation of
advanced filter

Cheers
 
K

KellTainer

Hi,

You can use this criterion. Assuming your control date is in B2 and
your column header is Date

Then
C1:E1 : Date
C2: =">="&DATE(YEAR(B2),MONTH(B2),1)
D2: ="<"&DATE(YEAR(B2),MONTH(B2) + 1, 1)
E2: ="<>"&B2

Then specify C1:E2 as the criterion.
 
D

Debra Dalgleish

In the criteria range, leave the heading cell blank.
In the cell below, enter a formula that refers to the control date, e.g.:

=AND(MONTH(A2)=MONTH($K$1),YEAR(A2)=YEAR($K$1))

where the control date is in cell K1, and the first date in the table is
in cell A2.

When you run the advanced filter, select the blank heading cell, and the
cell with the formula, as the criteria range.
 
R

R. Choate

Hi Debra,

That didn't work. The formula returned a "FALSE" and no rows were shown. Also, yesterday when I tried to use the AND function while
working on my own solution, it never worked. I did everything like you instructed. Any ideas?

Thanks,

Richard
--
RMC,CPA


In the criteria range, leave the heading cell blank.
In the cell below, enter a formula that refers to the control date, e.g.:

=AND(MONTH(A2)=MONTH($K$1),YEAR(A2)=YEAR($K$1))

where the control date is in cell K1, and the first date in the table is
in cell A2.

When you run the advanced filter, select the blank heading cell, and the
cell with the formula, as the criteria range.
 
D

Debra Dalgleish

Do the formulas return real dates?
What is entered in the control date cell? A real date, or text?
Can you give an example of a few rows of data, and what you'd expect if
you filtered them?
 
R

R. Choate

I'm not sure how this will come through but we'll see. The dates are real but they are returned by formulas, eg
=IF(ISBLANK(J11),"",J11). each cell in that column has a copy of that formula. I used the date format yyyymm to make it look like
this (200403). It is not text.
There are rows below this which say 200404. I would expect only those rows to show when filtered. By the way, this is only one
column of many in the table.


Collection Month
200403
200403
200403
200403


--
RMC,CPA


Do the formulas return real dates?
What is entered in the control date cell? A real date, or text?
Can you give an example of a few rows of data, and what you'd expect if
you filtered them?
 
R

R. Choate

Oh, I forgot, the control date cell also has a real date. A user enters it as eg 04/09/04 to indicate the date an invoice was paid.
The format for the cell re-formats it to look like all of the other dates.
--
RMC,CPA


Do the formulas return real dates?
What is entered in the control date cell? A real date, or text?
Can you give an example of a few rows of data, and what you'd expect if
you filtered them?
 
D

Debra Dalgleish

Somewhere on the worksheet, enter a couple of formulas to test the
control date, e.g.:
=Month($K$1)
=Year($K$1)

Do those formulas show the result you expected?

Then, test the date in a record with 200403 in the date column, using
the Month and Year functions, as above.

Do those formulas show the result you expected?

In the formula that I previously suggested for the criteria area:
=AND(MONTH(A2)=MONTH($K$1),YEAR(A2)=YEAR($K$1))

make sure that the reference to the control date cell is absolute: $K$1
and the reference to the data in the table is relative: A2

The formula will return the result for the first data row, so FALSE
result wouldn't affect the filter outcome.
 
R

R. Choate

It tested as a legitimate date. I perhaps should mention that some of the cells in the column returned zero-length text because the
formula calls for that if the precedent cell is blank. I don't know if that affects anything.
--
RMC,CPA


Somewhere on the worksheet, enter a couple of formulas to test the
control date, e.g.:
=Month($K$1)
=Year($K$1)

Do those formulas show the result you expected?

Then, test the date in a record with 200403 in the date column, using
the Month and Year functions, as above.

Do those formulas show the result you expected?

In the formula that I previously suggested for the criteria area:
=AND(MONTH(A2)=MONTH($K$1),YEAR(A2)=YEAR($K$1))

make sure that the reference to the control date cell is absolute: $K$1
and the reference to the data in the table is relative: A2

The formula will return the result for the first data row, so FALSE
result wouldn't affect the filter outcome.
 
D

Debra Dalgleish

No, the empty string won't affect the filter.
Did you test both the control date, and a date in a record?
Did you use an absolute reference to the control date in the criteria
formula?
 
R

R. Choate

I did all of those things. Nothing worked. Result was no records shown.
--
RMC,CPA


No, the empty string won't affect the filter.
Did you test both the control date, and a date in a record?
Did you use an absolute reference to the control date in the criteria
formula?
 

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


Top