Consulting

Results 1 to 4 of 4

Thread: Slicer vba code

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location

    Slicer vba code

    Hi,

    Looking for a code which can be applied on slicers.

    as and when we select something on slicer it should automatically take me to data sheet.

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,877
    There are no Slicer events that can be used (at least I don't think so), nor does trying to use Worksheet_TableUpdate work here.
    In the attached I've done what you asked; I've used Sheet1's Worksheet_Calculate event handler to activate that sheet, but for that to work I needed to put a formula on that sheet which needs to be recalculated when the table changes (see cell R1) - it might be better to put a Total row at the bottom of the table.
    But this has the potential to be very irritating for the user, every change switches them back to the data table, so should they want to make more than one change, they have to keep on flipping back and forth between the sheets. In addition, anything else that might cause that sheet to recalculate will also activate that sheet.

    This can be made more selective by having a hidden pivot table somewhere and then using the its various pivot table event handlers. It could be made very selective about when the Data table sheet is activated. I haven't written any code for that yet, but come back should it be necessary.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,738
    Location
    Quote Originally Posted by Veeru View Post
    Hi,

    Looking for a code which can be applied on slicers.

    as and when we select something on slicer it should automatically take me to data sheet.

    Thanks in advance
    Since it looks like you want to stay on the data sheet, why not just use filters?

    You can even get fancy and add a ListBox control to each column
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  4. #4
    VBAX Contributor
    Joined
    Jul 2017
    Posts
    110
    Location
    Yes that makes no sense...p45cal......can you elobrate Paul...how to use fancy and a listbox here

Posting Permissions

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