Begin and End Dates
Various factors might be at work here but the most likely
suspect is how you are storing the dates. The first thing
to check is the format of the column of cells containing
your dates: are these truly date values, or could they be
text? If they are text you will need to convert them to
true date values to make everything work.
Assuming you did take care of this, the next potential
problem is how you are referring to your dates in your VBA
code. Be sure to put everything into Date type variables
before you do any comparisons or filtering. Your
MessageBoxes are returning text so are you sure you are
converting the values properly to dates? I like using the
DateValue function for this purpose since it is easy to
use and mistakes can be easily seen and debugged.
As for AdvancedFilter, that is a pretty big topic and hard
to get into it without more specifics of what you want to
know. I don't think I would use Autofilter here, though:
I think I would just find the proper rows in the specified
date range and set that up as the source data range for
the PivotTable.
Hope this helps.
-----Original Message-----
I have tried this from multiple angles but have yet to
make it work.
I have a database of unknown size (between 3 and 30000+
entries) that are
sorted (or they have become sorted) by date.
I only want to put the relevant dates into the Pivot
table.
I want the user to enter the dates in a MsgBox type thing
because they can
be assured of putting them in the wrong cell.
The macro has to work without user input (except for the
dates) as I can not
be there with them.
I was trying to just step through the whole thing and
flag the rows that
enter/exit the defined date range but I can't seem to be
able to relate the
MsgBox date (date1 and date2) to the dates in the A
column. I can't get the
autofilter to understand my date1 and date2 (As Date)
either. Also the
advanced filter doesn't seem to work for me( everything I
have read about it
doesn't seem to relate to the advancedFilter I have.
Excel 2002)
A B C
01/14/2004 XXX YYY
01/15/2004 XXX YYY
.
|