+ Reply to Thread
Results 1 to 2 of 2

VBA Pivot Tables - Object defined error

  1. #1
    Registered User
    Join Date
    09-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question VBA Pivot Tables - Object defined error

    I have a sheet which is auto generated and I want to add pivot tables to it. The macros work fine individually but when I try to run all 3 macros in one go, the 3rd one will fail with an object-defined error no matter which order I run them in. Any ideas?

    Please Login or Register  to view this content.
    This fails on the addDisciplinaryPivot part of the btnMacros_Click sub. Changing the order the pivot tables are made has the same effect (the 3rd pivot table will fail), for example this:

    Please Login or Register  to view this content.
    Fails on addAttendancePivot. I've spent a day on this now and it's wasting too much time. I could write my own pivot table faster than fixing this problem.

    The lines that fail are the ones that include ActiveWorkbook.PivotCaches.Add
    Last edited by retrohead; 09-26-2012 at 12:07 PM. Reason: ActiveWorkbook.PivotCaches.Add

  2. #2
    Registered User
    Join Date
    09-26-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: VBA Pivot Tables - Object defined error

    Well I solved the problem (as random as it is).

    Selecting a different sheet seems to work. At the end of each of the functions that create the pivots, I added this which now seems to work:

    ActiveWorkbook.Sheets("Attendance").Select

    Fixed code:

    Please Login or Register  to view this content.

+ Reply to Thread

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