+ Reply to Thread
Results 1 to 6 of 6

Pivot table macro not working and I'm at a lose as to why

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Pivot table macro not working and I'm at a lose as to why

    I have attached a worksheet that is driving me crazy. The code that I am using is listed below:

    HTML Code: 
    I know this code works because I have used it many, many times and it gives the pivot results I am looking for. I really don't know what the problem is here. Any thoughts are welcome.

    Thanks

    Eddie
    Attached Files Attached Files
    Last edited by punter; 09-03-2014 at 11:25 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Pivot table macro not working and I'm at a lose as to why

    I suspect the error is in named range.
    If I change this line

    Set cacheOfPt = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("ReceivingSourceData"))
    INTO

    Set cacheOfPt = ThisWorkbook.PivotCaches.Create(xlDatabase, Sheets("Receiving").Range("A7:F1614"))
    it works.
    It know PT will not work if you have a complete blank rows or columns, but could not see this problem on your data.
    Last edited by AB33; 09-03-2014 at 11:12 AM.

  3. #3
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Re: Pivot table macro not working and I'm at a lose as to why

    Thank you for your quick reply.

    If I force the range to be A7:F1614 won't I have to update that every time I change the source data?

    Thanks

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Pivot table macro not working and I'm at a lose as to why

    this seems to work also
    CHANGE

    Sheets("Receiving").Select
    Set cacheOfPt = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("ReceivingSourceData"))
    INTO
    Sheets("Receiving").Select
    Set cacheOfPt = ActiveWorkbook.PivotCaches.Create(xlDatabase, "ReceivingSourceData")
    EDIT: just a note....I commented out the On Error stuff because it was masking errors....HTH
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  5. #5
    Forum Contributor
    Join Date
    10-28-2003
    Location
    Happyville, USA
    MS-Off Ver
    365
    Posts
    300

    Re: Pivot table macro not working and I'm at a lose as to why

    Quote Originally Posted by judgeh59 View Post
    this seems to work also
    CHANGE

    Sheets("Receiving").Select
    Set cacheOfPt = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("ReceivingSourceData"))
    INTO
    Sheets("Receiving").Select
    Set cacheOfPt = ActiveWorkbook.PivotCaches.Create(xlDatabase, "ReceivingSourceData")
    EDIT: just a note....I commented out the On Error stuff because it was masking errors....HTH
    This seems to have worked. Thanks so much.

    Eddie

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Pivot table macro not working and I'm at a lose as to why

    glad I could help....and thanks for the rep points

+ 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. Pivot table field settings Macro - works in 2010 but not working in 2007
    By ellwto in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-06-2014, 05:03 AM
  2. Excel Pivot change fild name wo lose pivot layout
    By Belden in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-05-2014, 06:51 AM
  3. Pivot Table Filter Macro Not working
    By sm9748 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2013, 03:43 AM
  4. Updating pivot table filters through a macro has stopped working, help please
    By JasperTata in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-21-2012, 09:53 AM
  5. Macro for Pivot table not working properly
    By oakman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2007, 09:46 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