Results 1 to 1 of 1

how to display the last 7 days in a pivot chart - Macro

Threaded View

hattrick_123a how to display the last 7... 09-22-2011, 08:45 PM
  1. #1
    Registered User
    Join Date
    04-28-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2003
    Posts
    24

    Question how to display the last 7 days in a pivot chart - Macro

    Hi there

    This relates to another post I have here but is slightly different.

    I am looking to write a macro that makes the last 7 days in the pivot chart visible. I am assuming all days are visible before the macro is run. So then when the macro is run, only the last 7 days are visible in the pivot chart.

    My initial thinking is to make all the dates invisible/hidden and then make the last 7 days visible. But I am not too sure if this is the best method?

    The below macro is a simple recording of the “date” being filtered to only show last weeks days.

    How do I write the below code so it could be written generically so I can put it in a loop to do every pivot chart in a workbook? I can work on the loop myself. I just need a hand with this part please.


    Sub Macro2()
    '
    ' Macro2 Macro
    '
    '
    ActiveSheet.PivotTables("PivotTable2").PivotFields("date").PivotFilters.Add _
    Type:=xlDateLastWeek
    End Sub


    Thanks
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1