PDA

View Full Version : Solved: Macro to Show last seven days on Pivot Table



Endorphin
12-14-2008, 04:58 PM
First of all Merry Christmas !!!

Any Ideas??

I have created a pivot table with data that gets updated on every Friday for the previous seven days, the displayed data gets selected by the user from a predetermined list (last 7 days button) and arranged by macros run by the user pressing the last 7 days button.

Now the problem?.

How would you get a macro to realise that today is say Sunday (14/12/2008) and it needs to show data from Saturday (06/12/2008) to Friday (12/12/2008) and so on for the following weeks when they come round.

The macro only needs to show the lat 7 days stored.

If this makes any sense you really need to stop drinking that mulled wine!!

Neil

MaximS
12-14-2008, 10:24 PM
Hi Endorphin,

try this to find your dates:


Sub Date_Finder()

Dim Start, Finish As Date
Dim LastWeek As Long

LastWeek = Weekday(Date - 7, vbSaturday)
Start = Date - (6 + LastWeek)
Finish = Start + 6

End Sub

david000
12-15-2008, 10:42 AM
http://www.contextures.com/excelfiles.html#Pivot
This file >>>> PT0014 - Filter from Worksheet Date Range

Great Example of this technique. Just in case. :*)

Endorphin
12-15-2008, 02:48 PM
Will give it a go, Thanks for your help !!!