+ Reply to Thread
Results 1 to 7 of 7

Change source data of existing PivotTable

  1. #1
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105

    Change source data of existing PivotTable

    I'm trying to write a macro that will gather raw data from any file you select and create a PivotTable. Trouble is, the workbook that obtains the macro already has a PivotTable in it. I don't want to delete the PivotTable and build another from scratch via code, all I'd like is for the user to select the file with the data (a new workbook is created every month that has the new data) and simply use that as the source data for the PivotTable already in place. I think I've almost got it, I've got all the error checks in place except for the very last line of code I get the "Object Required" error message although (I believe) I've already got the Object in place. Heres the code and all of the functions it uses:

    Please Login or Register  to view this content.
    As always, your help is very much appreciated!

    EDIT: I tried changing the code some and the new code is reflected above. Now I get "Run-time error '91': Object variable or With block variable not set" triggered by the code "Set SourceRng"
    Last edited by fecurtis; 05-29-2008 at 05:46 PM.

  2. #2
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Bump, back to the top.

  3. #3
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    I've made more changes, I think I'm almost there. Now when I run it I get the error:

    Run-time error '1004':
    The PivotTable field name is not valid. To create a PivotTable report, you must use data that is organized as a list with labeled columns. If you are changing the name of a PivotTable field, you must type a new name for the field.

    When I do it manually, it works just fine. There aren't any changes to the PivotTable field or anything like that so I'm stumped. Heres the new code:

    Please Login or Register  to view this content.
    The part in bold is what triggers the error.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    fecurtis,

    Please read forum rules below and then add the link to the cross post.

    VBA Noob
    Last edited by VBA Noob; 05-30-2008 at 04:07 PM.
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    Per the rules, this thread can also be found here:

    http://www.ozgrid.com/forum/showthread.php?t=92472

    While not new to forums, I am new to forums related to VBA programming. Never really thought about cross posting and I should've read all the rules other than the first couple since yeah I'd be peeved if I worked for a while on a code to help someone only to learn that it was already solved a while ago by someone else on another forum.

    My mistake, won't happen again. Sincerest apologies. Thankfully the problem was caught before someone did spend a while trying to figure out my issue only to learn that its already been solved.
    Last edited by fecurtis; 05-30-2008 at 04:24 PM.

  6. #6
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    In the event that anyone would like to try to solve this issue, I've posted the question in this thread as well:

    http://www.mrexcel.com/forum/showthr...77#post1584177

    I will let you know if its solved on that forum ASAP when/should it occur.

  7. #7
    Forum Contributor
    Join Date
    04-30-2008
    Posts
    105
    SOLVED!

    If anyone ever runs into a similar problem, this link may be of use:

    http://www.mrexcel.com/forum/showthread.php?t=322563

+ 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