+ Reply to Thread
Results 1 to 5 of 5

Select all dates on a slicer between two dates

  1. #1
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Select all dates on a slicer between two dates

    Hi all,

    I have a sheet with around 30 pivots on it displayed in two columns - pivots in the left columns display data per day, data in the right columns display the same data but per month

    I have a slicer that links to all the day pivots (so about 15 pivots), that I need to amend daily to show the date range between today and today - 30. Basically I'm unselecting the last selected item on the slicer list, and selecting todays date. The raw data behind the pivots is updated daily to include the latest lines, so is ever-increasing in size. Because of this constant expansion of data, I can't filter one of the pivots directly, as to do that it firsts clears all the filters which expands the pivot to fit all the dates into it - with the monthly pivots right next door, eventually it'll bump into it and create an error!

    Having tried out the macro recorder, I get a long list of actions to select/deselect each slicer item, which is no good to me due to the increasing size of the list each day. After some searching about I came across this code which I've tailored for my own file and what I want to achieve:

    Please Login or Register  to view this content.
    My issue is that I can't seem to get the code to check if a date is greater than/equal to, presumably because it's in string format it's like comparing text against text and therefore won't treat it as a number. I get that, but how can I look at the slicer item as a date, rather than as text so I can check the <= / >= part?
    Last edited by dancing-shadow; 05-25-2017 at 07:57 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Select all dates on a slicer between two dates

    Hi,

    You might try using the actual date values instead
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Select all dates on a slicer between two dates

    Hi,

    Can you upload the workbook and manually add an example of what you want to see.
    I must admit it's unusual to hear that you have a workbook with 30 pivot tables since one of the principal benefits of a PT is its ability to show different views of the same data at the click of a slicer or the drag and drop of a field. Personally I've never seen an operational workbook with more than three PTs.

    Neither is it obvious why you are showing Dates in the Column labels area rather than the rows area. This would stop your PT expanding to the right.

    As to being able to see just the last month have you considered adding an extra column to your data that identifies all dates in the last month and use this field in a Slicer or PT filter to pick out the last month's data. e.g.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Are you using a dynamic range name for your data and using the range name as the source for your PT so that you don't need to worry about constantly changing the PT range. All you then need to do is to use a Sheet Activate event macro to automatically refresh the PT when the PT sheet is activated.

    Upload the workbook if you feel there's still a problem.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    07-19-2010
    Location
    Huddersfield, UK
    MS-Off Ver
    Excel 2007, 2010
    Posts
    167

    Re: Select all dates on a slicer between two dates

    xlnitwit - thank you so much, this is perfect!! Exactly what I was after

    Richard - to clear up your queries, the layout of many tables and a daily (rolling 30 days)/monthly view is how the end user wants it displayed, not my choice at all, but they pay my wages so I can't complain too much! This is also the same for the dates in column labels as opposed to rows. It's how they've always had it, and how they like it. Changes have been suggested but never agreed to, so this format remains unchanged.
    The original tables were formulae connected to pivots on a slave sheet, but it was messy and took forever to process all the calculations, so I changed it all for pivots.
    I tried using a slave column in my data, to throw a simple Y/N for each date within my specific date range, but I found that the pivots would either show all dates whether they were filtered on the Y or not, or it would show the specified dates but no data for any date that didn't exist. The pivot option for 'Show all items with no data' cannot also be filtered on - it's a one or the other type deal, which doesn't work for what I need.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Select all dates on a slicer between two dates

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Select dates in Slicer through macro
    By Pawan Kokate in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2017, 04:28 AM
  2. Replies: 2
    Last Post: 03-20-2015, 01:57 PM
  3. Select Multiple Dates In Report Filter Pivot Table But Dates Are Not Static
    By biasedobserver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2014, 03:38 PM
  4. Group dates in a pivot table slicer
    By lora2014 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-02-2014, 01:25 AM
  5. Replies: 0
    Last Post: 05-18-2013, 03:29 AM
  6. [SOLVED] Auto filling dates based on previously entered dates and averaging numbers if dates equal
    By grambograham in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-11-2012, 03:21 PM
  7. How to make slicer sort dates correctly?
    By Elias Hedberg in forum Excel General
    Replies: 1
    Last Post: 08-04-2011, 10:26 AM

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