+ Reply to Thread
Results 1 to 10 of 10

Pivot table VBA

  1. #1
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Pivot table VBA

    Hi,

    Does anyone knows a VBA code which will delete all rows from a pivot table when a range from that pivot table doesn't match a condition?

    Example:

    There is a cell (A1) where I introduce a date. When running the code, I would like that all rows from the pivot table where the date is higher than that one introduced in "A1" will delete.

    Any help would be much appreciated.

    Kind regards,

  2. #2
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,067

    Re: Pivot table VBA

    Can you post the file to work on? OR a dummy example in the same format.

    Thanks
    Remember you are unique, like everyone else

  3. #3
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Pivot table VBA

    Hi noboffinme,

    I have attached an example of what I am looking for.

    Thanks!
    Attached Files Attached Files

  4. #4
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,067

    Re: Pivot table VBA

    Hi pezalmendra,

    I've created a Pivot on your data & applied a rule that filters out records before 12/09/14.

    If you Right click a Cell in the Pivots 'Date' Column go to 'Filter' >> 'Date Filters' & Apply the rule 'Greater Than or Equal to' & select a date.

    The Pivot will remove the requested dates.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Pivot table VBA

    Hi noboffinme,

    Thanks for your reply! I was actually looking a way of just deleting the rows because I want to keep the dates and sequence as it is shown in the pivot table...

    Is there a code which would search in the range of dates of the pivot table and delete those rows in which the date is > than the one in cell C2?

    Regards

  6. #6
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,067

    Re: Pivot table VBA

    So do you want the Macro to delete the Rows in your 'Table' & then a Pivot Table' will update on that changed data?

  7. #7
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Pivot table VBA

    Yes exactly!

  8. #8
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,067

    Re: Pivot table VBA

    Paste this code into a Module in your workbook, go to Macros & Run the 'Delete_rows_on_cond' Macro.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Pivot table VBA

    Excellent noboffinme!

    Just what I wanted! Thanks!

    Regards

  10. #10
    Forum Contributor noboffinme's Avatar
    Join Date
    08-29-2013
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003/7/10/13/16/19
    Posts
    1,067

    Re: Pivot table VBA

    Glad I could help.

+ 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. Replies: 6
    Last Post: 07-31-2014, 12:56 PM
  2. Collapse/Expand - Pivot table Fields - Need equivalent option in Excel VBA Pivot table
    By ragavendraph in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2012, 03:00 PM
  3. Replies: 1
    Last Post: 06-22-2010, 09:10 AM
  4. Replies: 1
    Last Post: 06-20-2010, 04:00 AM
  5. Return pivot table range...not the data table, the PIVOT TABLE!
    By Air_Cooled_Nut in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2008, 01:07 PM

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